We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent abd03c5 commit 2a61607Copy full SHA for 2a61607
1 file changed
Random Password Generator.java
@@ -1,13 +1,14 @@
1
-import java.util.*;
+import java.security.SecureRandom;
2
3
public class PasswordGen {
4
public static void main(String[] args) {
5
String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@#$%";
6
- Random r = new Random();
7
- String pass = "";
+ SecureRandom r = new SecureRandom();
+ StringBuilder pass = new StringBuilder();
8
9
- for (int i = 0; i < 10; i++)
10
- pass += chars.charAt(r.nextInt(chars.length()));
+ for (int i = 0; i < 10; i++) {
+ pass.append(chars.charAt(r.nextInt(chars.length())));
11
+ }
12
13
System.out.println("Generated Password: " + pass);
14
}
0 commit comments