package com.wecloud.utils;

/**
 * @Author wenzhida
 * @Date 2022/2/23 14:57
 * @Description 随机工具类
 */
public class RandomUtil {

    /**
     * 生成短信验证码
     * @return
     */
    public static String generateVerifyCode() {
        Integer verifyCode = (int) ((Math.random() * 9 + 1) * 100000);
        return verifyCode.toString();
    }

    /**
     * 生成随机字符串
     * @param length 字符串长度
     * @return
     */
    public static String generateRandomStr(int length) {
        String src = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        char[] m = src.toCharArray();
        StringBuilder strSb = new StringBuilder();
        for (int j = 0; j < length; j++) {
            char c = m[(int) (Math.random() * 36)];
            strSb.append(c);
        }
        return strSb.toString();
    }

}
