This commit is contained in:
2025-11-22 14:02:20 +08:00
parent 98a04f8fbe
commit 381ae80eeb
59 changed files with 1930 additions and 1817 deletions

View File

@@ -0,0 +1,38 @@
package com.czg.utils;
import cn.hutool.core.lang.id.NanoId;
/**
* @author ww
* @description
*/
public class CzgRandomUtils {
private static final char[] DEFAULT_ALPHABET =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
/**
* 默认长度
*/
public static final int DEFAULT_SIZE = 12;
/**
* 随机生成指定长度的字符串
*
* @return 随机字符串
*/
public static String randomString() {
return NanoId.randomNanoId(null, DEFAULT_ALPHABET, DEFAULT_SIZE);
}
/**
* 随机生成指定长度的字符串
*
* @param length 字符串长度
* @return 随机字符串
*/
public static String randomString(int length) {
return NanoId.randomNanoId(null, DEFAULT_ALPHABET, length);
}
}