public class Test {
private static final String key = "fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF";
private static final int[] base58Position = {11, 10, 3, 8, 4, 6};
private static final long xorNumber = 177451812;
private static final long subNumber = 8728348608L;
public static long bvToAv(String bv) {
long result = 0;
for (int i = 0; i < base58Position.length; i++) {
result = (long) (result + key.indexOf(bv.substring(base58Position[i], base58Position[i] + 1)) * Math.pow(58, i));
}
return (result - subNumber) ^ xorNumber;
}
public static String avToBv(long av) {
av = (av ^ xorNumber) + subNumber;
String[] tmp = "BV1 4 1 7 ".split("");
for (int i = 0; i < base58Position.length; i++) {
tmp[base58Position[i]] = key.split("")[(int) (av / Math.pow(58, i) % 58)];
}
return String.join("", tmp);
}
public static void main(String[] args) {
String bv = "BV197411D7Gf"; // 替换为要转换的 BV 号
long av = bvToAv(bv);
System.out.println("AV: " + (av));
System.out.println("BV: " + avToBv(av));
}
}
bv与av互转
最新推荐文章于 2024-04-12 15:26:30 发布