{"id":1401,"library":"blake3","title":"BLAKE3 Hash Function","description":"blake3-py provides high-performance Python bindings for the BLAKE3 cryptographic hash function, implemented in Rust. It offers a fast, secure, and modern hashing algorithm. The current version is 1.0.8, with releases typically driven by updates to the underlying Rust `blake3` crate, PyO3, or support for new Python versions.","status":"active","version":"1.0.8","language":"python","source_language":"en","source_url":"https://github.com/oconnor663/blake3-py","tags":["cryptography","hashing","security","blake3","rust"],"install":[{"cmd":"pip install blake3","lang":"bash","label":"Install blake3"}],"dependencies":[],"imports":[{"symbol":"blake3","correct":"import blake3"}],"quickstart":{"code":"import blake3\n\n# One-shot hashing\ndata = b\"Hello, BLAKE3!\"\nhash_result = blake3.blake3(data).hexdigest()\nprint(f\"One-shot hash: {hash_result}\")\n\n# Incremental hashing\nhasher = blake3.Hasher()\nhasher.update(b\"First part. \")\nhasher.update(b\"Second part.\")\nincremental_hash = hasher.finalize().hexdigest()\nprint(f\"Incremental hash: {incremental_hash}\")\n","lang":"python","description":"Demonstrates both one-shot hashing of a complete data block and incremental hashing for streaming data."},"warnings":[{"fix":"Ensure Rust and Cargo are installed (e.g., via `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`) before attempting to install `blake3` if you encounter build errors.","message":"Installation may require a Rust toolchain. While pre-built wheels are available for most common platforms and Python versions, if a suitable wheel is not found for your specific environment (OS, architecture, Python version), pip will attempt to build the library from source. This requires the Rust programming language and Cargo package manager to be installed on your system.","severity":"gotcha","affected_versions":"All"},{"fix":"Update your Rust toolchain to version 1.80 or newer using `rustup update`.","message":"Minimum Supported Rust Version (MSRV) increases over time. For versions 1.0.7 and later, the MSRV is Rust 1.80. If you are building from source, an older Rust toolchain might lead to compilation failures.","severity":"gotcha","affected_versions":">=1.0.7"},{"fix":"Initialize `hasher = blake3.Hasher()` and feed data chunks using `hasher.update(data_chunk)` before calling `hasher.finalize()`.","message":"For optimal performance and memory usage with large datasets, use `blake3.Hasher()` for incremental hashing. The `blake3.blake3()` function is designed for one-shot hashing of data that fits comfortably in memory. Repeated calls to `blake3.blake3()` on chunks of a large file will be inefficient compared to using the `Hasher` object.","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure the 'blake3' library is fully and correctly installed. If building from source, verify your Rust toolchain is properly configured and up-to-date (refer to warning 0 and 1 for Rust-related issues). Consider reinstalling 'blake3' in a clean virtual environment or checking for environment-specific compilation problems.","message":"Running code that attempts to use 'blake3.Hasher()' can result in an 'AttributeError: module 'blake3' has no attribute 'Hasher'' if the 'Hasher' object is not available. This usually indicates an incomplete or corrupted installation of the 'blake3' library, or a version-specific issue where 'Hasher' is not exposed. Although 'blake3.blake3()' might still function for one-shot hashes, the incremental 'Hasher' API will be unusable, causing application breakage.","severity":"breaking","affected_versions":"All"}],"env_vars":null,"search_vec":"'1.0.8':35 'algorithm':30 'bind':12 'blake3':1,5,15,46,58 'blake3-py':4 'crate':47 'cryptograph':16 'cryptographi':55 'current':32 'driven':39 'fast':25 'function':3,18 'hash':2,17,29,56 'high':9 'high-perform':8 'implement':19 'modern':28 'new':52 'offer':23 'perform':10 'provid':7 'py':6 'pyo3':48 'python':11,53 'releas':37 'rust':21,45,59 'secur':26,57 'support':50 'typic':38 'under':44 'updat':41 'version':33,54","created_at":"2026-04-09T03:46:21.135524+00:00","updated_at":"2026-04-16T00:24:17.440237+00:00","problems":[{"fix":"Install the package using pip: `pip install blake3`","cause":"The 'blake3' Python package is not installed in the current Python environment, or the environment where it's installed is not the one being used.","error":"ModuleNotFoundError: No module named 'blake3'"},{"fix":"Ensure you are using the correct import statement `import blake3` or `from blake3 import blake3` as needed. If the issue persists, try reinstalling the package: `pip uninstall blake3` then `pip install blake3`. Also, check for any local Python files or folders named `blake3.py` or `blake3` that might be shadowing the installed package.","cause":"This error often occurs when Python tries to find a submodule named 'blake3' within the 'blake3' package itself, which is typically due to an incorrect import statement, a corrupted installation, or a naming conflict (e.g., a local file named `blake3.py`).","error":"ModuleNotFoundError: No module named 'blake3.blake3'"},{"fix":"Install or update the Rust toolchain: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` followed by `rustup update`. Ensure a compatible C compiler (like GCC or Clang) is installed and accessible in your system's PATH. On Windows, installing 'Build Tools for Visual Studio' might resolve it.","cause":"This error indicates a problem during the compilation of the underlying Rust BLAKE3 library, often due to a missing or outdated Rust toolchain, a C compiler issue, or incompatibility with the current Python or OS environment, especially when pre-built wheels are not available.","error":"error: failed to compile blake3"},{"fix":"Encode the string to bytes before passing it to the BLAKE3 hasher, typically using UTF-8 encoding: `hasher.update(my_string.encode('utf-8'))`","cause":"The BLAKE3 hash function operates on byte sequences, but a Python string (`str`) was provided as input without explicit encoding.","error":"TypeError: argument must be an object with the buffer protocol or an immutable bytes-like object, not str"},{"fix":"Ensure the key passed to `blake3.blake3(key=...)` or `blake3.blake3(key_material=...)` is a bytes object of exactly 32 bytes. You can generate a random 32-byte key using `secrets.token_bytes(32)`.","cause":"When using BLAKE3's keyed hashing mode, the provided key must be precisely 32 bytes in length.","error":"ValueError: key must be exactly 32 bytes"}],"ecosystem":"pypi","meta_description":null,"install_score":80,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.0.9","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/oconnor663/blake3-py","docs":null,"changelog":null,"pypi":"https://pypi.org/project/blake3/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["auth-security","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":"verified"}}