{"id":17991705,"url":"https://github.com/hakavlad/catpig","last_synced_at":"2025-04-04T04:16:40.694Z","repository":{"id":196327098,"uuid":"664298387","full_name":"hakavlad/catpig","owner":"hakavlad","description":"A memory-hard password-hashing function","archived":false,"fork":false,"pushed_at":"2023-10-12T15:15:58.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-09T23:17:08.495Z","etag":null,"topics":["blake2b","hashing","kdf","memory-hard","pbkdf","shake256"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hakavlad.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-09T14:43:40.000Z","updated_at":"2023-10-12T14:39:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"603880b0-d42e-4f8d-ae99-ff315e304335","html_url":"https://github.com/hakavlad/catpig","commit_stats":null,"previous_names":["hakavlad/catpig"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakavlad%2Fcatpig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakavlad%2Fcatpig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakavlad%2Fcatpig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakavlad%2Fcatpig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hakavlad","download_url":"https://codeload.github.com/hakavlad/catpig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247117762,"owners_count":20886439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["blake2b","hashing","kdf","memory-hard","pbkdf","shake256"],"created_at":"2024-10-29T19:23:32.871Z","updated_at":"2025-04-04T04:16:40.679Z","avatar_url":"https://github.com/hakavlad.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Logo: кошка Свинья](https://i.imgur.com/5AHvXQm.jpeg)\n\n# catpig\n\n[![License](https://img.shields.io/badge/License-CC0-blue)](https://github.com/hakavlad/catpig/blob/main/LICENSE)\n[![Releases](https://img.shields.io/github/v/release/hakavlad/catpig)](https://github.com/hakavlad/catpig/releases)\n[![PyPI](https://img.shields.io/pypi/v/catpig?color=blue\u0026label=PyPI)](https://pypi.org/project/catpig/)\n[![CodeQL](https://github.com/hakavlad/catpig/actions/workflows/codeql.yml/badge.svg)](https://github.com/hakavlad/catpig/actions/workflows/codeql.yml)\n\n`catpig` is a [memory-hard](https://en.wikipedia.org/wiki/Memory-hard_function) [password-hashing function](https://en.wikipedia.org/wiki/Key_derivation_function).\n\nIt uses `SHAKE256` to create data that will occupy memory of a given size (`space_mib`).\n\nThe data will be read in 4096-byte chunks with a pseudo-random offset and hashed by the `BLAKE2b` function.\n\nMemory access patterns during reading of the first half of a given amount of data depend only on the salt (iMHF). Memory access patterns during reading of the second half of a given amount of data also depend the results of previous steps (dMHF).\n\nThe output length is always 64 bytes.\n\n## Install\n\n```bash\npip install catpig\n```\n\n## Usage\n\n```python\nfrom catpig.catpig import catpig\n\nderived_key = catpig(password, salt, space_mib, passes)\n```\n\n`password` and `salt` must be bytes-like objects.\n\n`space_mib` defines the memory usage in mebibytes.\n\n`passes` defines the amount of data that will be read and hashed by the `BLAKE2b` function. One pass corresponds to reading a data size equal to `space_mib`.\n\n## Test vectors\n\n```python\n\u003e\u003e\u003e from catpig.catpig import catpig\n\u003e\u003e\u003e\n\u003e\u003e\u003e catpig(b'', b'', space_mib=1, passes=1).hex()\n'831e43e4a352066a8ade279225d95e7543203cce8ce77348e4f7898741f32b9f1b8793393aa69cef84016d5f391aa9a7840050c5c59b9defd6cc324cb44e3e9a'\n\u003e\u003e\u003e\n\u003e\u003e\u003e catpig(password=b'password', salt=b'salt', space_mib=64, passes=4).hex()\n'd1999b1a7749de88ac8b6f1d8659ccf3b1c2cfe7fd84426bddc75de4b9f57bc07293cca52bb22e0915945d462bb760dfab02d78a713e65620307bc08b8fb7905'\n\u003e\u003e\u003e\n\u003e\u003e\u003e catpig(password=b'passphrase', salt=b'NaCl', space_mib=512, passes=8).hex()\n'83b6181449eb405e7bb662642090c077298e445f63846a98f18b8102df5e80f8a50dcf43f951ce8e893aac5beb23d33e5282624fd288fac4d07b8647f6c9bffe'\n\u003e\u003e\u003e\n\u003e\u003e\u003e catpig(password=b'new_passphrase', salt=b'SodiumChloride', space_mib=5000, passes=15).hex()\n'b4f96ceddf5c46380f6a425ebf2a30372cccfb3e4d7d95fd1cfc7c64910142eca3b7e61c20e32db7c97c72230c3b63abf1802dc068513297b67c274267fd1dde'\n```\n\n## Warnings\n\n- The author is not an expert in cryptography.\n- `catpig` has not been independently audited.\n\n## Requirements\n\n- Python \u003e= 3.6\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhakavlad%2Fcatpig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhakavlad%2Fcatpig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhakavlad%2Fcatpig/lists"}