/** * 随机生成八位数字验证码 * @Date 2020/3/18 14:17 * @param activityId 活动ID * @throws * @return */ private static String randomCode(Long activityId) { int maxNum = 10; int i; int count = 0; char[] str = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; StringBuffer pwd = new StringBuffer(""); Random r = new Random(); while(count < 8){ i = Math.abs(r.nextInt(maxNum)); if (i >= 0 && i < str.length) { pwd.append(str[i]); count ++; } } return pwd.toString(); }
随机生成八位数字验证码
最新推荐文章于 2024-05-08 01:22:38 发布