-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPassword Checker.py
More file actions
49 lines (42 loc) · 1.78 KB
/
Password Checker.py
File metadata and controls
49 lines (42 loc) · 1.78 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
import string
# Function to assess password strength
def assess_password_strength(password):
# Define criteria
length_criteria = len(password) >= 8
uppercase_criteria = any(char.isupper() for char in password)
lowercase_criteria = any(char.islower() for char in password)
digit_criteria = any(char.isdigit() for char in password)
special_criteria = any(char in string.punctuation for char in password)
# Evaluate strength based on criteria
if length_criteria and uppercase_criteria and lowercase_criteria and digit_criteria and special_criteria:
return "Very Strong"
elif length_criteria and uppercase_criteria and lowercase_criteria and digit_criteria:
return "Strong"
elif length_criteria and uppercase_criteria and lowercase_criteria:
return "Moderate"
elif length_criteria and lowercase_criteria and digit_criteria:
return "Moderate"
elif length_criteria and uppercase_criteria and digit_criteria:
return "Moderate"
elif length_criteria and special_criteria:
return "Moderate"
elif length_criteria and lowercase_criteria:
return "Weak"
else:
return "Very Weak"
# Main function for interactive usage
def main():
print("Password Strength Evaluator")
print("Criteria:")
print("- At least 8 characters long")
print("- Contains uppercase and lowercase letters")
print("- Contains numbers")
print("- Contains special characters")
while True:
password = input("\nEnter a password to assess (or 'quit' to exit): ")
if password.lower() == 'quit':
break
strength = assess_password_strength(password)
print(f"Password strength: {strength}")
if __name__ == "__main__":
main()