项目初始化

This commit is contained in:
2025-08-24 11:25:21 +08:00
parent 504519faf3
commit b8a9548bce
2 changed files with 126 additions and 76 deletions

View File

@@ -0,0 +1,34 @@
package com.mini.capi.utils;
import java.security.SecureRandom;
public class vToken {
private static final String DEFAULT_TOKEN = "3774e79ac55aff6d1afc0f94bfaf131d";
private static final SecureRandom RAND = new SecureRandom();
private static final char[] HEX = "0123456789abcdef".toCharArray();
public static boolean isValidToken(String token) {
return DEFAULT_TOKEN.equals(token);
}
/**
* 随机32位
*/
public static String nextHex32() {
byte[] bytes = new byte[16]; // 16 字节 = 128 bit
RAND.nextBytes(bytes);
char[] chars = new char[32];
for (int i = 0, j = 0; i < 16; i++) {
int v = bytes[i] & 0xFF;
chars[j++] = HEX[v >>> 4];
chars[j++] = HEX[v & 0x0F];
}
return new String(chars);
}
}