A small, dependency-free password-strength policy module for Python, implementing guidance from NIST SP 800-63B Rev. 4 (2025) and the OWASP Authentication Cheat Sheet (2021). It contains only policy logic — no UI — so it can be imported by any program that needs to validate or score a password.
The module follows a length-first, NIST-aligned model rather than mandatory composition rules:
- Hard pass/fail is driven by NIST §5.1.1:
- minimum length (≥ 8 characters), and
- the password must not appear in a common/breached password list, and
- it must not contain context-specific personal info (name, username, etc.).
- Character-class diversity (lower/upper/digit/symbol) and extra length are advisory bonuses that raise a 0–10 score for user feedback — they are not hard requirements, consistent with NIST guidance.
- Obvious keyboard patterns (
qwerty,123456, …) incur a small penalty.
The common-password list is downloaded once from
SecLists and cached locally
(common_pw_cache.txt, git-ignored). If the download fails, a small built-in
fallback list is used.
load_common_passwords(url=..., cache_file=...) -> frozenset[str]
check_personal_info(password, context) -> list[str]
score_password(password, common_set, context=None) -> PasswordResult
PasswordResult # NamedTuple: acceptable, score, verdict, detail,
# passed, failed, personal_hitsfrom password_policy import load_common_passwords, score_password
common = load_common_passwords()
result = score_password("correct-horse-battery-staple", common,
context={"first": "John", "username": "jdoe"})
print(result.verdict) # e.g. "STRONG"
print(result.detail) # "STRONG | Length: 28 | Score: 10/10"
for note in result.failed:
print(" -", note)- NIST SP 800-63B Rev. 4 — Digital Identity Guidelines, §5.1.1 Memorized Secrets
- OWASP Authentication Cheat Sheet (2021)
MIT — see LICENSE.