/** * 生成8位随机数 * @return */ public String getNonce_str() { String SYMBOLS = "0123456789"; Random RANDOM = new SecureRandom(); char[] nonceChars = new char[8]; for (int index = 0; index < nonceChars.length; ++index) { nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length())); } return new String(nonceChars); }