统计
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user