-
Notifications
You must be signed in to change notification settings - Fork 0
/
Strength_Checker.py
40 lines (33 loc) · 1.13 KB
/
Strength_Checker.py
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
def printStrongNess(input_string):
n = len(input_string)
# Initializing necessary characters with false
hasLower = False
hasUpper = False
hasDigit = False
hasSpecialChar = False
normalChars = "abcdefghijklmnopqrstu"
"vwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 "
# Checking necessary characters in string
for i in range(n):
if input_string[i].islower():
hasLower = True
if input_string[i].isupper():
hasUpper = True
if input_string[i].isdigit():
hasDigit = True
if input_string[i] not in normalChars:
hasSpecialChar = True
# Strength of password
print("----------------------------------------------------------------")
print("Strength of password:- ", end = "")
if (hasLower and hasUpper and
hasDigit and hasSpecialChar and n > 8):
print("Strong")
print("----------------------------------------------------------------\n")
elif ((hasLower or hasUpper) and
(hasDigit or hasSpecialChar) and n >= 8):
print("Moderate")
print("----------------------------------------------------------------\n")
else:
print("Weak")
print("----------------------------------------------------------------\n")