forked from janavipandole/Foodie
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordChecker.java
More file actions
33 lines (26 loc) · 1019 Bytes
/
PasswordChecker.java
File metadata and controls
33 lines (26 loc) · 1019 Bytes
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
import java.util.Scanner;
public class PasswordStrengthChecker {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("🔑 Enter your password: ");
String password = scanner.nextLine();
String strength = evaluatePassword(password);
System.out.println("Password Strength: " + strength);
scanner.close();
}
public static String evaluatePassword(String password) {
int score = 0;
if (password.length() >= 8) score++;
if (password.matches(".*[A-Z].*")) score++;
if (password.matches(".*[a-z].*")) score++;
if (password.matches(".*\\d.*")) score++;
if (password.matches(".*[!@#$%^&*()].*")) score++;
switch (score) {
case 5: return "💪 Very Strong";
case 4: return "👍 Strong";
case 3: return "👌 Moderate";
case 2: return "😬 Weak";
default: return "❌ Very Weak";
}
}
}