{"id":16937035,"url":"https://github.com/oconnor663/blake3-py","last_synced_at":"2025-05-15T09:07:35.475Z","repository":{"id":40192849,"uuid":"243825104","full_name":"oconnor663/blake3-py","owner":"oconnor663","description":"Python bindings for the BLAKE3 cryptographic hash function","archived":false,"fork":false,"pushed_at":"2025-05-01T08:13:37.000Z","size":306,"stargazers_count":158,"open_issues_count":2,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-11T03:37:22.351Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oconnor663.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":"2020-02-28T18:06:47.000Z","updated_at":"2025-05-03T00:22:02.000Z","dependencies_parsed_at":"2023-12-12T09:24:20.430Z","dependency_job_id":"aea279a0-c816-48ee-becf-c39c305d5189","html_url":"https://github.com/oconnor663/blake3-py","commit_stats":{"total_commits":282,"total_committers":7,"mean_commits":"40.285714285714285","dds":0.2092198581560284,"last_synced_commit":"217473b9dddd9595d9dd82eefe9f0a4231cf741b"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oconnor663%2Fblake3-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oconnor663%2Fblake3-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oconnor663%2Fblake3-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oconnor663%2Fblake3-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oconnor663","download_url":"https://codeload.github.com/oconnor663/blake3-py/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254310515,"owners_count":22049469,"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":[],"created_at":"2024-10-13T20:58:31.289Z","updated_at":"2025-05-15T09:07:30.464Z","avatar_url":"https://github.com/oconnor663.png","language":"Python","funding_links":[],"categories":["Cryptography \u0026 Hashing"],"sub_categories":[],"readme":"# blake3-py [![tests](https://github.com/oconnor663/blake3-py/actions/workflows/tests.yml/badge.svg?branch=master\u0026event=push)](https://github.com/oconnor663/blake3-py/actions/workflows/tests.yml) [![PyPI version](https://badge.fury.io/py/blake3.svg)](https://pypi.python.org/pypi/blake3)\n\nPython bindings for the [official Rust implementation of\nBLAKE3](https://github.com/BLAKE3-team/BLAKE3), based on\n[PyO3](https://github.com/PyO3/pyo3). These bindings expose all the features of\nBLAKE3, including extendable output, keying, and multithreading. The basic API\nmatches that of Python's standard\n[`hashlib`](https://docs.python.org/3/library/hashlib.html) module.\n\n## Examples\n\n```python\nfrom blake3 import blake3\n\n# Hash some input all at once. The input can be bytes, a bytearray, or a memoryview.\nhash1 = blake3(b\"foobarbaz\").digest()\n\n# Hash the same input incrementally.\nhasher = blake3()\nhasher.update(b\"foo\")\nhasher.update(b\"bar\")\nhasher.update(b\"baz\")\nhash2 = hasher.digest()\nassert hash1 == hash2\n\n# Hash the same input fluently.\nassert hash1 == blake3(b\"foo\").update(b\"bar\").update(b\"baz\").digest()\n\n# Hexadecimal output.\nprint(\"The hash of 'hello world' is\", blake3(b\"hello world\").hexdigest())\n\n# Use the keyed hashing mode, which takes a 32-byte key.\nimport secrets\nrandom_key = secrets.token_bytes(32)\nmessage = b\"a message to authenticate\"\nmac = blake3(message, key=random_key).digest()\n\n# Use the key derivation mode, which takes a context string. Context strings\n# should be hardcoded, globally unique, and application-specific.\ncontext = \"blake3-py 2020-03-04 11:13:10 example context\"\nkey_material = b\"usually at least 32 random bytes, not a password\"\nderived_key = blake3(key_material, derive_key_context=context).digest()\n\n# Extendable output. The default digest size is 32 bytes.\nextended = blake3(b\"foo\").digest(length=100)\nassert extended[:32] == blake3(b\"foo\").digest()\nassert extended[75:100] == blake3(b\"foo\").digest(length=25, seek=75)\n\n# Hash a large input using multiple threads. Note that this can be slower for\n# inputs shorter than ~1 MB, and it's a good idea to benchmark it for your use\n# case on your platform.\nlarge_input = bytearray(1_000_000)\nhash_single = blake3(large_input).digest()\nhash_two = blake3(large_input, max_threads=2).digest()\nhash_many = blake3(large_input, max_threads=blake3.AUTO).digest()\nassert hash_single == hash_two == hash_many\n\n# Hash a file with multiple threads using memory mapping. This is what b3sum\n# does by default.\nfile_hasher = blake3(max_threads=blake3.AUTO)\nfile_hasher.update_mmap(\"/big/file.txt\")\nfile_hash = file_hasher.digest()\n\n# Copy a hasher that's already accepted some input.\nhasher1 = blake3(b\"foo\")\nhasher2 = hasher1.copy()\nhasher1.update(b\"bar\")\nhasher2.update(b\"baz\")\nassert hasher1.digest() == blake3(b\"foobar\").digest()\nassert hasher2.digest() == blake3(b\"foobaz\").digest()\n```\n\n## Installation\n\n```\npip install blake3\n```\n\nAs usual with Pip, you might need to use `sudo` or the `--user` flag\nwith the command above, depending on how you installed Python on your\nsystem.\n\nThere are binary wheels [available on\nPyPI](https://pypi.org/project/blake3/#files) for most environments. But\nif you're building the source distribution, or if a binary wheel isn't\navailable for your environment, you'll need to [install the Rust\ntoolchain](https://rustup.rs).\n\n## C Bindings\n\nExperimental bindings for the official BLAKE3 C implementation are available in\nthe [`c_impl`](c_impl) directory. These will probably not be published on PyPI,\nand most applications should prefer the Rust-based bindings. But if you can't\ndepend on the Rust toolchain, and you're on some platform that this project\ndoesn't provide binary wheels for, the C-based bindings might be an\nalternative.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foconnor663%2Fblake3-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foconnor663%2Fblake3-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foconnor663%2Fblake3-py/lists"}