-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtempCodeRunnerFile.py
More file actions
45 lines (42 loc) · 1.31 KB
/
tempCodeRunnerFile.py
File metadata and controls
45 lines (42 loc) · 1.31 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
45
import re
def pwd_chk(password):
strength=0
remark=[]
if len(password)>=8:
strength+=1
remark.append("Length is sufficient")
else:
remark.append("Length should be at least 8 characters")
if re.search(r'[A-Z]',password):
strength+=1
remark.append("Contains uppercase letter")
else:
remark.append("Should contain at least one uppercase letter")
if re.search(r'[a-z]',password):
strength+=1
remark.append("Contains lowercase letter")
else:
remark.append("Should contain at least one lowercase letter")
if re.search(r'[0-9]',password):
strength+=1
remark.append("Contains a digit")
else:
remark.append("Should contain at least one digit")
if re.search(r'[!@#$%^&*(),.?":{}|<>]',password):
strength+=1
remark.append("Contains special character")
else:
remark.append("Should contain a special character")
if strength==5:
rating="Strong Password"
elif strength>=3:
rating="Moderate Password"
else:
rating="Weak Password"
return rating,remark
password=input("Enter your password to check its strength: ")
rating,remark=pwd_chk(password)
print(f"Password Rating: {rating}")
print("Remarks:")
for r in remark:
print(f"- {r}")