-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordgenerator.java
More file actions
22 lines (22 loc) · 889 Bytes
/
Passwordgenerator.java
File metadata and controls
22 lines (22 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.*;
public class Password {
public static void main(String[] args) {
int length = 10;
System.out.println(Password1(length));
}
static char[] Password1(int len) {
System.out.println("Generating password using random() : ");
System.out.print("Your new password is : ");
String Capital_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String Small_chars = "abcdefghijklmnopqrstuvwxyz";
String numbers = "0123456789";
String symbols = "!@#$%^&*_=+-/.?<>)";
String values = Capital_chars + Small_chars + numbers + symbols;
Random rndm_method = new Random();
char[] password = new char[len];
for (int i = 0; i < len; i++) {
password[i] = values.charAt(rndm_method.nextInt(values.length()));
}
return password;
}
}