forked from nishant-Tiwari24/python-foundation-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpswdchecker.py
74 lines (65 loc) · 2.1 KB
/
pswdchecker.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import string
import getpass
def check_pwd():
password = getpass.getpass("Enter Password: ")
strength = 0
remarks = ''
lower_count = upper_count = num_count = wspace_count = special_count = 0
for char in list(password):
if char in string.ascii_lowercase:
lower_count += 1
elif char in string.ascii_uppercase:
upper_count +=1
elif char in string.digits:
num_count += 1
elif char == ' ':
wspace_count +=1
else:
special_count +=1
if lower_count >= 1:
strength +=1
if upper_count >= 1:
strength +=1
if num_count >= 1:
strength +=1
if wspace_count>=1:
strength +=1
if special_count>=1:
strength +=1
if strength == 1:
remarks = "Very Bad Password!!! Change ASAP"
elif strength == 2:
remarks = "Not A Good Password!!! Change ASAP"
elif strength ==3:
remarks = "It's a weak password, consider changing"
elif strength == 4:
remarks = "It's a hard password, but can be better"
elif strength == 5:
remarks = "A very strong password"
print('Your password has: ')
print(f"{lower_count} lowercase characters")
print(f"{upper_count} uppercase characters")
print(f"{num_count} numeric characters")
print(f"{wspace_count} whitespace characters")
print(f"{special_count} special characters")
print(f"Password Strength:{strength}")
print(f"Hint: {remarks}")
def ask_pwd(another_pwd=False):
valid = False
if another_pwd:
choice=input('Do you want to enter another pwd (y/n): ')
else:
choice=input('Do you want to check pwd (y/n): ')
while not valid:
if choice.lower() == 'y':
return True
elif choice.lower() == 'n':
return False
else:
print('Invalid, Try Again')
if __name__ == '__main__':
print('+++ welcome to PWD checker +++')
ask_pw = ask_pwd()
while check_pwd:
check_pwd()
ask_pw = ask_pwd(True)