-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPassword_Test1.py
More file actions
44 lines (35 loc) · 1.28 KB
/
Password_Test1.py
File metadata and controls
44 lines (35 loc) · 1.28 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
42
43
44
# Small program to determine the strength of Users Password
__author__ = 'Dzhud' #on Github
def checkPasswordStrength(password=''):
SPECIAL_CHARACTERS = '!@#$%^&*()'
strength = [0, 0, 0, 0, 0]
messages = ('Ah! At least a lowercase letter must be included.',
'Oops! Forgot an uppercase letter?',
'Missing at least a number',
'A minimum of one special character must be added.',
'Password must be minimum 7 characters')
for letter in password:
if letter.islower():
strength[0] = 1
elif letter.isupper():
strength[1] = 1
elif letter.isdigit():
strength[2] = 1
elif letter in SPECIAL_CHARACTERS:
strength[3] = 1
elif ' ' in password:
print('Nope! Sorry. Cannot add space to password')
return False
if len(password) > 6:
strength [4] = 1
print()
for count in range(len(strength)):
if strength[count] == 0:
print (messages[count])
if 0 in strength:
return False
else:
print ("Now that's a strong password mate!")
return True
if __name__ == "__main__":
checkPasswordStrength('Br34!dkkmms ')