package com.hfkj.common.utils;

import java.util.Random;

/**
 * 生成工具类
 * @className: GenerateUtil
 * @author: HuRui
 * @date: 2023/5/23
 **/
public class GenerateUtil {

    /**
     * 生成随机字符串
     * @param length  长度
     * @return
     */
    public static String generateRandomString(int length) {
        String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        StringBuilder sb = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            int index = random.nextInt(chars.length());
            sb.append(chars.charAt(index));
        }
        return sb.toString();
    }

}
