{"id":18905477,"url":"https://github.com/utility-libraries/passwordlib-py","last_synced_at":"2026-01-23T02:20:17.035Z","repository":{"id":193228925,"uuid":"688373859","full_name":"utility-libraries/passwordlib-py","owner":"utility-libraries","description":"utility library to verify, hash, compare and more for passwords","archived":false,"fork":false,"pushed_at":"2024-10-13T15:16:49.000Z","size":453,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-19T09:13:54.961Z","etag":null,"topics":["password-hash","password-security","password-strength","python3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/password-library/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/utility-libraries.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-09-07T08:06:31.000Z","updated_at":"2024-10-11T19:28:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"6c761e8b-d138-48db-8a8b-4a8ce9950b86","html_url":"https://github.com/utility-libraries/passwordlib-py","commit_stats":null,"previous_names":["playerg9/passwordlib-py","utility-libraries/passwordlib-py"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/utility-libraries/passwordlib-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utility-libraries%2Fpasswordlib-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utility-libraries%2Fpasswordlib-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utility-libraries%2Fpasswordlib-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utility-libraries%2Fpasswordlib-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utility-libraries","download_url":"https://codeload.github.com/utility-libraries/passwordlib-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utility-libraries%2Fpasswordlib-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28678051,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T01:00:35.747Z","status":"online","status_checked_at":"2026-01-23T02:00:08.296Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["password-hash","password-security","password-strength","python3"],"created_at":"2024-11-08T09:12:05.755Z","updated_at":"2026-01-23T02:20:17.000Z","avatar_url":"https://github.com/utility-libraries.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# passwordlib-py\nutility library to verify, hash, compare and more for passwords\n\n\u003c!-- TOC --\u003e\n* [passwordlib-py](#passwordlib-py)\n  * [Installation](#installation)\n  * [Algorithms](#algorithms)\n  * [Example usage](#example-usage)\n  * [Roadmap](#roadmap)\n\u003c!-- TOC --\u003e\n\n## Installation\n\nJust run `pip install password-library`\n\n## Algorithms\n\n\u003e List of supported algorithms\n\n| Algorythm | Comment    |\n|-----------|------------|\n| sha1      |            |\n| sha224    |            |\n| sha256    |            |\n| sha384    |            |\n| sha512    |            |\n| sha3_224  |            |\n| sha3_256  |            |\n| sha3_384  |            |\n| sha3_512  |            |\n| shake_128 |            |\n| shake_256 |            |\n| blake2b   | Not Tested |\n| blake2s   | Not Tested |\n| md5       |            |\n\n\n## Example usage\n\npasswordlib offers an easy interface to create password-hashes\n```python\nfrom passwordlib import util as pwutil\n\nhashed = pwutil.hash_password(\"my_secret\")\n\nprint(pwutil.compare_password(\"your_secret\", hashed))  # False\nprint(pwutil.compare_password(\"my_secret\", hashed))  # True\n\nprint(pwutil.extract_algorythm(hashed))  # sha256\nprint(pwutil.extract_iterations(hashed))  # 100_000\nprint(pwutil.extract_salt(hashed))  # b'...'\nprint(pwutil.extract_hashed(hashed))  # b'...'\n```\nyou can also configure the algorithms or number of iterations\n```python\nfrom passwordlib import util as pwutil, config as pwconfig\n\n# either globally\npwconfig.DEFAULT_ALGORITHM = \"md5\"\npwconfig.DEFAULT_ITERATIONS = 1_000_000\npwconfig.DEFAULT_SALT_LENGTH = 64\n\n# or per instance\npwutil.hash_password(\n  password='password',\n  algorithm=\"md5\", iterations=1_000_000, salt_length=64,\n)\n```\nit also offers the `PasswordAttribute` class to automatically hash attributes on objects\n```python\nfrom passwordlib.attr import PasswordAttribute\n\nclass User:\n    name: str\n    password = PasswordAttribute()\n\nuser = User()\nprint(user.password)  # None\nuser.password = \"secret\"\nprint(user.password)  # b'\\x06sha256\\x00\\x01\\x86\\xa0\\x00 \\x07\\xcfg\\x0ec\\xa6D\\xea\\xae\\x03S\\xa1\\xfcz\\xaew\\x02\\x8b\\xf1\\xe5\\xaf\\x83n\u0026\\x87'\\xcdRi!\\xd9\\xe7\\x00@qV\\xd3\\x81\\x113:*\"\\x05\\xba\\x12Xb\\x04\\xeb\\x08Sn\\x08Z\\x9f\\x89\\xa50~\\xa0\\xb4\\xbd.\\xc6\\x18\"\\xf9l\\xeds\\xbc\\xc2B\\xa7\\xef\\xa1\\x8a\\x7f3\\xc1u\\x17d\\xce\\xf2\\x98+l\\x86\\xb7\\x1c\\xb4\\xf0\\x07t8\\xc9'\n```\nyou can also check if a password is commonly used\n```python\nfrom passwordlib.commonly_used import is_commonly_used\n\nprint(is_commonly_used(\"password\"))  # True\nprint(is_commonly_used(\"123456\"))  # True\nprint(is_commonly_used(\"matrix\"))  # True\nprint(is_commonly_used(\"password-library\"))  # False\nprint(is_commonly_used(\"TifnedjothUj\"))  # False\n```\nand be able to validate a password against different criteria\nto ensure a password is safe.\n\n```python\nfrom passwordlib.analyzer import Analyzer\n\n\n# may not seem safe at first, but think:\n# 9 digits,lowercase and symbols, not commonly used and no repeating characters\nresult = Analyzer(\"my_secret\")\nprint(result.is_secure)  # True\nprint(result.is_highly_secure)  # False\nprint(result.score)  # 5\n\nprint(result.contains_lowercase)  # True\nprint(result.contains_uppercase)  # False\nprint(result.contains_digits)  # False\nprint(result.contains_symbols)  # True\nprint(result.length)  # 9\nprint(result.max_consecutive_character)  # 1\nprint(result.is_commonly_used)  # False\n\n# you can do such a check here:\nnumber_of_security_features = sum((\n  result.contains_lowercase,\n  result.contains_uppercase,\n  result.contains_digits,\n  result.contains_symbols,\n  result.length \u003e= 8,\n  result.charset_length \u003e (result.length // 2)\n))\nif number_of_security_features \u003c 5 or result.is_commonly_used:\n  raise PasswordTooWeakError(result.password)\n\n# here are more examples for you\nr = Analyzer(\"password\")\nprint(r.score, r.is_secure, r.is_highly_secure)\n# 0 False False\nr = Analyzer(\"123456\")\nprint(r.score, r.is_secure, r.is_highly_secure)\n# 0 False False\nr = Analyzer(\"matrix\")\nprint(r.score, r.is_secure, r.is_highly_secure)\n# 0 False False\nr = Analyzer(\"password-library\")\nprint(r.score, r.is_secure, r.is_highly_secure)\n# 7 True False\nr = Analyzer(\"TifnedjothUj\")\nprint(r.score, r.is_secure, r.is_highly_secure)\n# 6 True False\nr = Analyzer(\"passwoooooooooooooord\")\nprint(r.score, r.is_secure, r.is_highly_secure)\n# 1 False False\n```\n\n## Roadmap\n\n- [ ] passwordlib\n  - [X] passwordlib.util\n    - [X] def hashing\n    - [X] def comparing\n    - [X] def dumping\n    - [X] def loading\n  - [X] passwordlib.attr\n    - [X] class PasswordAttribute\n  - [X] passwordlib.commonly_used\n    - [X] def is_common_password\n  - [X] passwordlib.Analyzer\n    - [X] class Analyzer\n  - [ ] passwordlib.validator\n    - [ ] class PasswordValidator \n    - [ ] passwordlib.validator.rules\n- [ ] Documentation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futility-libraries%2Fpasswordlib-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futility-libraries%2Fpasswordlib-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futility-libraries%2Fpasswordlib-py/lists"}