Skip to content

Commit aaba2a4

Browse files
committed
chore(password):password check method
1 parent 76cc78f commit aaba2a4

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

meow/password/passwords.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,39 @@ def generate_memmory_password():
3737
secret = get_random_password(length=4)
3838

3939
# Combine the animal name, positive adjective, and secret and return the result
40-
return f"{positive_adjective}_{animal_name}_{secret}"
40+
return f"{positive_adjective}_{animal_name}_{secret}"
41+
42+
43+
def check_password_strength(password):
44+
"""
45+
This method checks the strength of a given password.
46+
47+
It checks the following:
48+
1. Length: At least 8 characters.
49+
2. At least one uppercase letter.
50+
3. At least one lowercase letter.
51+
4. At least one digit.
52+
5. At least one special character.
53+
54+
"""
55+
# Check length
56+
if len(password) < 8:
57+
return "Weak"
58+
59+
# Check for uppercase letters
60+
if not any(char.isupper() for char in password):
61+
return "Weak"
62+
63+
# Check for lowercase letters
64+
if not any(char.islower() for char in password):
65+
return "Weak"
66+
67+
# Check for digits
68+
if not any(char.isdigit() for char in password):
69+
return "Weak"
70+
71+
# Check for special characters
72+
if not any(char in string.punctuation for char in password):
73+
return "Weak"
74+
75+
return "Strong"

0 commit comments

Comments
 (0)