package com.qiuguo.iot.base.utils;

import java.util.Random;

public class StringUtils extends cn.hutool.core.util.StrUtil{
    private static final String chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    /**
     * 获取随机字符串 0-9, a-z, A-Z
     * @param length 个数
     * @return String
     */
    public static String getRandomStr(int length) {
        if (length <= 3) {
            length = 3;
        }
        StringBuilder sb = new StringBuilder();
        int charsLen = chars.length();
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            sb.append(chars.charAt(random.nextInt(charsLen)));
        }
        return sb.toString();
    }
}
