生成8位随机数

   /**
     * 生成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);
    }

 

posted @ 2019-07-23 19:09  fightForLife  阅读(3402)  评论(1编辑  收藏  举报