更改 Password 实现。

This commit is contained in:
2023-04-19 06:05:02 +08:00
parent 104bffb0e8
commit 30f29bb4b3
3 changed files with 22 additions and 50 deletions

View File

@@ -1,6 +1,6 @@
package xyz.zhouxy.plusone.util;
import java.util.concurrent.ThreadLocalRandom;
import java.security.SecureRandom;
public final class RandomUtil {
private RandomUtil() {
@@ -8,7 +8,7 @@ public final class RandomUtil {
}
public static String randomStr(char[] sourceCharacters, int length) {
ThreadLocalRandom random = ThreadLocalRandom.current();
SecureRandom random = new SecureRandom();
char[] result = new char[length];
for (int i = 0; i < length; i++) {
result[i] = sourceCharacters[random.nextInt(sourceCharacters.length)];