-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotepad_checker.py
More file actions
40 lines (33 loc) · 1.02 KB
/
notepad_checker.py
File metadata and controls
40 lines (33 loc) · 1.02 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
import re
def check_password_strength(password):
strength = 0
remarks = ""
# Rule 1: Length
if len(password) >= 8:
strength += 1
else:
remarks += "Password should be at least 8 characters long.\n"
# Rule 2: Upper and Lowercase
if re.search(r'[A-Z]', password) and re.search(r'[a-z]', password):
strength += 1
else:
remarks += "Use both uppercase and lowercase letters.\n"
# Rule 3: Numbers
if re.search(r'\d', password):
strength += 1
else:
remarks += "Include numbers.\n"
# Rule 4: Special Characters
if re.search(r'[!@#$%^&*(),.?":{}|<>]', password):
strength += 1
else:
remarks += "Include special characters.\n"
if strength == 4:
return "Strong password 💪"
elif strength == 3:
return "Moderate password 😐\n" + remarks
else:
return "Weak password ⚠️\n" + remarks
# Take input from the user
password = input("Enter your password: ")
print(check_password_strength(password))