统一工具类命名规则。

This commit is contained in:
2024-04-03 16:20:41 +08:00
parent 09b5b1e0f3
commit cc34af04c2
12 changed files with 37 additions and 74 deletions

View File

@@ -0,0 +1,18 @@
package xyz.zhouxy.plusone.commons.util;
import java.security.SecureRandom;
public final class RandomTools {
private RandomTools() {
throw new IllegalStateException("Utility class");
}
public static String secureRandomStr(char[] sourceCharacters, int length) {
SecureRandom random = new SecureRandom();
char[] result = new char[length];
for (int i = 0; i < length; i++) {
result[i] = sourceCharacters[random.nextInt(sourceCharacters.length)];
}
return String.valueOf(result);
}
}