MCPcopy Create free account
hub / github.com/geekcomputers/Python / check_password_strength

Function check_password_strength

password_checker_code.py:3–28  ·  view source on GitHub ↗
(password)

Source from the content-addressed store, hash-verified

1import string
2
3def check_password_strength(password):
4 strength = 0
5
6 # Criteria 1: Length (Must be at least 8 characters)
7 if len(password) >= 8:
8 strength += 1
9
10 # Criteria 2: Must contain Digits (0-9)
11 has_digit = False
12 for char in password:
13 if char.isdigit():
14 has_digit = True
15 break
16 if has_digit:
17 strength += 1
18
19 # Criteria 3: Must contain Uppercase Letters (A-Z)
20 has_upper = False
21 for char in password:
22 if char.isupper():
23 has_upper = True
24 break
25 if has_upper:
26 strength += 1
27
28 return strength
29
30if __name__ == "__main__":
31 print("--- Password Strength Checker ---")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected