add random text pool

This commit is contained in:
Timi
2026-06-05 11:59:35 +08:00
parent ceb781292d
commit 112e6290f0

View File

@@ -15,8 +15,16 @@ import java.util.UUID;
*/
public class Text {
public static String LETTER_POOL = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static String NUMBER_POOL = "0123456789";
public static String LETTER_NUMBER_POOL = LETTER_POOL + LETTER_POOL;
public static String PASSWORD_CHAR_POOL = LETTER_NUMBER_POOL + "!#$%&()*+,-./:;<=>?@[]^_`{|}~";
/** 十六进制小写 */
public static char[] HEX_DIGITS_LOWER = "0123456789abcdef".toCharArray();
public static char[] HEX_DIGITS_LOWER = (NUMBER_POOL + "abcdef").toCharArray();
/**
* 是否为半角字符
@@ -150,7 +158,7 @@ public class Text {
}
public static String randomString(int length) {
return randomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", length);
return randomString(LETTER_NUMBER_POOL, length);
}
public static String randomString(String pool, int length) {