Contents
随机数
1 private static final String SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2
3 private static final Random RANDOM = new SecureRandom();
4
5 /**
6 * 获取随机字符串 Nonce Str
7 *
8 * @return String 随机字符串
9 */
10 public static String generateNonceStr() {
11 char[] nonceChars = new char[32];
12 for (int index = 0; index < nonceChars.length; ++index) {
13 nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length()));
14 }
15 return new String(nonceChars);
16 }
17
18