{"id":8401,"library":"password-strength","title":"Password Strength","description":"The `password-strength` library (PyPI slug: `password-strength`, current version `0.0.3.post2`) provides tools for password strength assessment and validation. It allows defining a `PasswordPolicy` with various rules (e.g., minimum length, character types, entropy) to test if a password meets specified security requirements. The library also offers `PasswordStats` to get a normalized strength score and detailed analysis of a password. While the PyPI package itself was last updated in 2019, its GitHub repository shows more recent activity, suggesting ongoing relevance.","status":"active","version":"0.0.3.post2","language":"python","source_language":"en","source_url":"https://github.com/kolypto/py-password-strength","tags":["security","password","validation","strength","entropy"],"install":[{"cmd":"pip install password-strength","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"PasswordPolicy","correct":"from password_strength import PasswordPolicy"},{"symbol":"PasswordStats","correct":"from password_strength import PasswordStats"}],"quickstart":{"code":"from password_strength import PasswordPolicy, PasswordStats\n\n# Define a password policy\npolicy = PasswordPolicy.from_names(\n    length=8,\n    uppercase=1,\n    numbers=1,\n    special=1,\n    nonletters=1\n)\n\n# Test a password against the policy\npassword = \"StrongP@ssw0rd!\"\nerrors = policy.test(password)\n\nif not errors:\n    print(f\"Password '{password}' meets the policy requirements.\")\nelse:\n    print(f\"Password '{password}' failed the following checks: {', '.join(errors)}\")\n\n# Get detailed strength statistics\nstats = PasswordStats(password)\nprint(f\"\\nPassword entropy (bits): {stats.entropy_bits:.2f}\")\nprint(f\"Password complexity (0.00-0.99): {stats.complexity:.2f}\")\nprint(f\"Password strength (0.00-1.00): {stats.strength:.2f}\")","lang":"python","description":"This quickstart demonstrates how to define a password policy using `PasswordPolicy.from_names` and test a password against it. It also shows how to get detailed strength statistics, including entropy, complexity, and a normalized strength score using `PasswordStats`."},"warnings":[{"fix":"Prefer using `policy.test()` to get a list of failed rules or `PasswordStats().complexity` / `PasswordStats().strength` for a more user-friendly score, especially when providing feedback to end-users.","message":"The default entropy calculation might be less intuitive for users than a complexity score or explicit policy checks. While `entropy_bits` is a fundamental measure, `complexity` (0.00-0.99) or `strength` (0.00-1.00) are often more digestible for direct user feedback.","severity":"gotcha","affected_versions":"<=0.0.3.post2"},{"fix":"For enhanced security, consider adding custom checks for known weak patterns, dictionary words, or sequential characters, potentially by extending the `PasswordPolicy` or implementing separate validation functions. The library offers the flexibility to define custom validation rules or combine with other techniques.","message":"A password might pass basic length and character type rules but still contain easily guessable repetitions (e.g., 'aaaaaa', '123123'). The library's `Policy` object doesn't inherently check for overly repetitive patterns beyond what the entropy calculation might implicitly catch.","severity":"gotcha","affected_versions":"<=0.0.3.post2"},{"fix":"Define password requirements using `PasswordPolicy.from_names()` or by directly instantiating `PasswordPolicy` with desired rules, which is generally more readable and maintainable.","message":"Direct manipulation or reliance on `weak_bits`, `medium_bits`, `strong_bits` constants might be less recommended than using the `Policy` object's named rules, as policies provide a clearer, more configurable approach to defining acceptable passwords.","severity":"deprecated","affected_versions":"<=0.0.3.post2"}],"env_vars":null,"search_vec":"'0.0.3':15 '2019':74 'activ':81 'allow':26 'also':50 'analysi':61 'assess':22 'charact':36 'current':13 'defin':27 'detail':60 'e.g':33 'entropi':38,89 'get':54 'github':76 'last':71 'length':35 'librari':7,49 'meet':44 'minimum':34 'normal':56 'offer':51 'ongo':83 'packag':68 'password':1,5,11,20,43,64,86 'password-strength':4,10 'passwordpolici':29 'passwordstat':52 'post2':16 'provid':17 'pypi':8,67 'recent':80 'relev':84 'repositori':77 'requir':47 'rule':32 'score':58 'secur':46,85 'show':78 'slug':9 'specifi':45 'strength':2,6,12,21,57,88 'suggest':82 'test':40 'tool':18 'type':37 'updat':72 'valid':24,87 'various':31 'version':14","created_at":"2026-04-16T17:02:00.526741+00:00","updated_at":"2026-04-16T17:02:00.526741+00:00","problems":[{"fix":"Ensure the library is installed in your current environment using `pip install password-strength`. If using virtual environments, activate the correct one before running your script.","cause":"The library is not installed or the Python environment is incorrect.","error":"ModuleNotFoundError: No module named 'password_strength'"},{"fix":"Access validation methods on the `PasswordPolicy` object. For example, use `policy.test(password)` instead of `policy(password)`.","cause":"Attempting to call a `PasswordPolicy` object like a function instead of using its `test()` method.","error":"TypeError: 'PasswordPolicy' object is not callable"},{"fix":"Use `PasswordPolicy` for testing against defined rules (`policy.test(password)`). Use `PasswordStats` to get raw metrics like entropy or complexity (`PasswordStats(password).strength`).","cause":"Confusing `PasswordStats` (for analysis) with `PasswordPolicy` (for validation). `PasswordStats` provides statistical properties, not policy testing.","error":"AttributeError: 'PasswordStats' object has no attribute 'test'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.0.3.post2","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/kolypto/py-password-strength","docs":null,"changelog":null,"pypi":"https://pypi.org/project/password-strength/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["auth-security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}