-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpass.py
More file actions
40 lines (40 loc) · 1.1 KB
/
pass.py
File metadata and controls
40 lines (40 loc) · 1.1 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
password = input("Enter password: ")
score = 0
special_chars = "!@#$%^&*(),.?\":{}|<>_`~"
if len(password) >= 8:
score += 1
has_upper = False
has_lower = False
has_digit = False
has_special = False
for char in password:
if char.isupper():
has_upper = True
if char.islower():
has_lower = True
if char.isdigit():
has_digit = True
if char in special_chars:
has_special = True
if has_upper:
score += 1
if has_lower:
score += 1
if has_digit:
score += 1
if has_special:
score += 1
if score == 5:
print("Strong password!")
else:
print(f"Weak password. Your rating is {score}/5.")
if len(password) < 8:
print("- Password is too short (must be at least 8 characters).")
if not has_upper:
print("- Password needs at least one uppercase letter.")
if not has_lower:
print("- Password needs at least one lowercase letter.")
if not has_digit:
print("- Password needs at least one digit.")
if not has_special:
print("- Password needs at least one special character.")