-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
56 lines (39 loc) · 1.31 KB
/
code.py
File metadata and controls
56 lines (39 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
46
47
48
49
50
51
52
53
54
55
56
import re
def check_password_strength(password):
feedback = []
score = 0
if len(password) >= 8:
score += 1
else:
feedback.append("❌ Password should be at least 8 characters long.")
if re.search(r"[A-Z]", password):
score += 1
else:
feedback.append("❌ Include at least one uppercase letter (A-Z).")
if re.search(r"[a-z]", password):
score += 1
else:
feedback.append("❌ Include at least one lowercase letter (a-z).")
if re.search(r"[0-9]", password):
score += 1
else:
feedback.append("❌ Include at least one number (0-9).")
if re.search(r"[!@#$%^&*(),.?\":{}|<>]", password):
score += 1
else:
feedback.append("❌ Include at least one special character (!@#$...).")
if score == 5:
strength = "✅ Strong Password"
elif score >= 3:
strength = "🟡 Medium Password"
else:
strength = "🔴 Weak Password"
return strength, feedback
if __name__ == "__main__":
password = input("Enter a password to check its strength: ")
strength, suggestions = check_password_strength(password)
print("\nPassword Strength:", strength)
if suggestions:
print("\nSuggestions to improve:")
for tip in suggestions:
print("-", tip)