Skip to content

Commit ce48c83

Browse files
authored
Merge pull request #455 from siddharthtankariya/siddharthtankariya_checking_password_strength
Password Strength Checker
2 parents 5edba4a + ed0de95 commit ce48c83

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
public class PasswordStrength {
2+
public static void main(final String ar[]) {
3+
String password = AbraKadabra1287832FQENi;
4+
5+
boolean hasLetter = false;
6+
boolean hasDigit = false;
7+
boolean hasUpperCase = false;
8+
boolean hasLowerCase = false;
9+
10+
if (password.length() >= 8) {
11+
for (int i = 0; i < password.length(); i++) {
12+
char x = password.charAt(i);
13+
if (Character.isLetter(x)) {
14+
if (Character.isUpperCase(x)) {
15+
hasUpperCase = true;
16+
} else if (Character.isLowerCase(x)) {
17+
hasLowerCase = true;
18+
}
19+
hasLetter = true;
20+
} else if (Character.isDigit(x)) {
21+
hasDigit = true;
22+
}
23+
if (hasLetter && hasDigit && hasUpperCase && hasLowerCase) {
24+
break;
25+
}
26+
}
27+
if (hasLetter && hasDigit && hasUpperCase && hasLowerCase) {
28+
System.out.println("STRONG");
29+
} else {
30+
System.out.println("NOT STRONG");
31+
}
32+
} else {
33+
System.out.println("HAVE AT LEAST 8 CHARACTERS");
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)