mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-25 13:35:15 +08:00
update 电单车协议
This commit is contained in:
@@ -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位数随机数
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user