Skip to content

Commit

Permalink
close reugn#12: use SecureRandom
Browse files Browse the repository at this point in the history
  • Loading branch information
reugn committed Nov 13, 2019
1 parent f1b9363 commit 20ac4a0
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.reugn.devtools.utils;

import java.security.SecureRandom;
import java.util.Random;

public class PasswordGenerator {
Expand Down Expand Up @@ -30,7 +31,7 @@ private PasswordGenerator(PasswordGeneratorBuilder builder) {
public String generate(int length) {
if (dictionary.isEmpty()) return "";
StringBuilder password = new StringBuilder(length);
Random random = new Random(System.nanoTime());
Random random = new SecureRandom();
for (int i = 0; i < length; i++) {
password.append(dictionary.charAt(random.nextInt(dictionary.length())));
}
Expand Down

0 comments on commit 20ac4a0

Please sign in to comment.