MCPcopy Create free account
hub / github.com/OreosLab/bili / HelpUtil

Class HelpUtil

src/main/java/top/misec/utils/HelpUtil.java:16–85  ·  view source on GitHub ↗

av bv utils. @author Junzhou Liu @since 2020/10/11 20:49

Source from the content-addressed store, hash-verified

14 * @since 2020/10/11 20:49
15 */
16public class HelpUtil {
17 private static final String TABLE = "fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF";
18 private static final HashMap<String, Integer> MP = new HashMap<>();
19 private static final HashMap<Integer, String> MP2 = new HashMap<>();
20 private static int[] ss = {11, 10, 3, 8, 4, 6, 2, 9, 5, 7};
21 private static long xor = 177451812;
22 private static long add = 8728348608L;
23
24 public static long power(int a, int b) {
25 long power = 1;
26 for (int c = 0; c < b; c++) {
27 power *= a;
28 }
29
30 return power;
31 }
32
33 public static String bv2av(String s) {
34 long r = 0;
35 for (int i = 0; i < 58; i++) {
36 String s1 = TABLE.substring(i, i + 1);
37 MP.put(s1, i);
38 }
39 for (int i = 0; i < 6; i++) {
40 r = r + MP.get(s.substring(ss[i], ss[i] + 1)) * power(58, i);
41 }
42 return ((r - add) ^ xor) + "";
43 }
44
45 public static String av2bv(String st) {
46 long s = Long.parseLong(st.split("av")[1]);
47 StringBuilder sb = new StringBuilder("BV1 4 1 7 ");
48 s = (s ^ xor) + add;
49 for (int i = 0; i < 58; i++) {
50 String s1 = TABLE.substring(i, i + 1);
51 MP2.put(i, s1);
52 }
53 for (int i = 0; i < 6; i++) {
54 String r = MP2.get((int) (s / power(58, i) % 58));
55 sb.replace(ss[i], ss[i] + 1, r);
56 }
57 return sb.toString();
58 }
59
60 public static String userNameEncode(String userName) {
61 int s1 = userName.length() / 2;
62 int s2 = (s1 + 1) / 2;
63 return userName.substring(0, s2)
64 + String.join("", Collections.nCopies(s1, "*"))
65 + userName.substring(s1 + s2);
66 }
67
68 public static String utcTime(String utcTime){
69 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
70 //设置时区UTC
71 df.setTimeZone(TimeZone.getTimeZone("UTC"));
72 //格式化,转当地时区时间
73 Date after = null;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…