-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.java
More file actions
41 lines (33 loc) · 1.48 KB
/
main.java
File metadata and controls
41 lines (33 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.Scanner;
public class main {
public static void main(String[] args) {
PasswordGenerator pg = new PasswordGenerator();
PassStrength ps = new PassStrength();
Scanner sc = new Scanner(System.in);
System.out.println(">> Password Generator <<");
System.out.print("Enter password length: ");
int length = sc.nextInt();
if(length < 6) {
System.out.println("Error: Password length must be >= 6");
sc.close();
return;
}
System.out.print("Include uppercase letters? (y/n): ");
boolean useUpper = sc.next().equalsIgnoreCase("y");
System.out.print("Include lowercase letters? (y/n): ");
boolean useLower = sc.next().equalsIgnoreCase("y");
System.out.print("Include digits? (y/n): ");
boolean useDigits = sc.next().equalsIgnoreCase("y");
System.out.print("Include symbols? (y/n): ");
boolean useSymbol = sc.next().equalsIgnoreCase("y");
try { // Generate password and display strength
String password = pg.generatePassword(length, useUpper, useLower, useDigits, useSymbol);
System.out.println("Generated Password: " + password);
System.out.println("Password Strength: " + ps.strength(password));
}
catch (IllegalArgumentException e) { // Handle exception for invalid outputs
System.out.println(e.getMessage());
}
sc.close();
}
}