update 电单车协议

This commit is contained in:
Guoqs
2024-09-02 19:55:02 +08:00
parent a41264d1b9
commit 256e358be5
16 changed files with 245 additions and 115 deletions

View File

@@ -14,7 +14,7 @@ import java.util.Set;
public class RandomUtil {
private static final String SYMBOLS_NUM = "0123456789"; // 纯数字
//如果需加入字母就改成0123456789abcdefg...........
private static final String SYMBOLS_NUM_ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789";
// private static final String SYMBOLS_NUM_ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789";
private static final Random RANDOM = new SecureRandom();
@@ -24,7 +24,7 @@ public class RandomUtil {
* @return 随机数字
*/
public static String getSMSVerificationCode() {
return getRandomNumber(6);
return getRandomNumberStr(6);
}
/**
@@ -33,7 +33,7 @@ public class RandomUtil {
* @param length 需要的长度
* @return 随机数
*/
public static String getRandomNumber(int length) {
public static String getRandomNumberStr(int length) {
char[] nonceChars = new char[length]; //指定长度,自己可以设置
for (int index = 0; index < nonceChars.length; ++index) {
nonceChars[index] = SYMBOLS_NUM.charAt(RANDOM.nextInt(SYMBOLS_NUM.length()));
@@ -41,6 +41,10 @@ public class RandomUtil {
return new String(nonceChars);
}
public static int getRandomNumber(int length) {
return Integer.parseInt(getRandomNumberStr(length));
}
/**
* 获取一组不重复的6位数随机数
*