Skip to main content

Python bindings for the Rust blake3 crate

Project description

blake3-py Actions Status PyPI version

Python bindings for the Rust blake3 crate, based on PyO3. This a proof of concept, not yet fully-featured or production-ready. See also the soundness concerns below.

Example

import blake3

hash1 = blake3.blake3(b"foobarbaz").digest()

hasher = blake3.blake3()
hasher.update(b"foo")
hasher.update(b"bar")
hasher.update(b"baz")
hash2 = hasher.digest()

assert hash1 == hash2

print("The hash of 'hello world' is:",
      blake3.blake3(b"hello world").hexdigest())

If you've cloned the GitHub project, and you want to experiment with the scripts there, they work like this:

# Build the shared library first.
$ ./build.py

# Hash some input.
$ echo hello world | ./example.py
dc5a4edb8240b018124052c330270696f96771a63b45250a5c17d3000e823355

# Run the tests.
$ ./test.py

Installation

pip install blake3

As usual with Pip, you might need to use sudo or the --user flag with the command above, depending on how you installed Python on your system.

There are binary wheels available on PyPI for most environments, so most users do not need a Rust toolchain. If you're building the source distribution, or if a binary wheel isn't available for your environment, you'll need the nightly Rust toolchain (required by PyO3). This project includes a rust-toolchain file, so rustup will install and invoke the nightly toolchain automatically.

Features

Currently only basic hashing is supported, with the default 32-byte output size. Missing BLAKE3 features should be easy to add, though I'm not sure exactly what the API should look like. Missing features include:

  • variable-length output
  • an incremental output reader
  • the keyed hashing mode
  • the key derivation mode
  • optional multi-threading

Thread Safety and Soundness

This wrapper is not currently thread-safe. Like the hash implementations in the Python standard library, we release the GIL during update, to avoid blocking the entire process. However, that means that calling the update method from multiple threads at the same time is undefined behavior. We could solve this by putting a Mutex inside the wrapper type, but I'd like to get some expert advice about the best practice here first.

A deeper problem is that another thread might mutate a bytearray while we're hashing it, and while our Rust code is treating it as a &[u8]. That violates Rust's aliasing guarantees and is also technically undefined behavior. However, the only possible way to solve this while still supporting bytearray would be to retain the GIL. Again, I'm in need of expert advice.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blake3-0.1.2.tar.gz (13.8 kB view details)

Uploaded Source

Built Distributions

blake3-0.1.2-cp38-none-win_amd64.whl (119.2 kB view details)

Uploaded CPython 3.8 Windows x86-64

blake3-0.1.2-cp38-none-win32.whl (117.6 kB view details)

Uploaded CPython 3.8 Windows x86

blake3-0.1.2-cp38-cp38-manylinux1_x86_64.whl (755.6 kB view details)

Uploaded CPython 3.8

blake3-0.1.2-cp38-cp38-macosx_10_7_x86_64.whl (160.2 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

blake3-0.1.2-cp37-none-win_amd64.whl (119.2 kB view details)

Uploaded CPython 3.7 Windows x86-64

blake3-0.1.2-cp37-none-win32.whl (117.6 kB view details)

Uploaded CPython 3.7 Windows x86

blake3-0.1.2-cp37-cp37m-manylinux1_x86_64.whl (755.5 kB view details)

Uploaded CPython 3.7m

blake3-0.1.2-cp37-cp37m-macosx_10_7_x86_64.whl (160.2 kB view details)

Uploaded CPython 3.7m macOS 10.7+ x86-64

blake3-0.1.2-cp36-none-win_amd64.whl (119.8 kB view details)

Uploaded CPython 3.6 Windows x86-64

blake3-0.1.2-cp36-none-win32.whl (118.2 kB view details)

Uploaded CPython 3.6 Windows x86

blake3-0.1.2-cp36-cp36m-manylinux1_x86_64.whl (756.3 kB view details)

Uploaded CPython 3.6m

blake3-0.1.2-cp36-cp36m-macosx_10_7_x86_64.whl (160.9 kB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

blake3-0.1.2-cp35-none-win_amd64.whl (119.8 kB view details)

Uploaded CPython 3.5 Windows x86-64

blake3-0.1.2-cp35-none-win32.whl (118.2 kB view details)

Uploaded CPython 3.5 Windows x86

blake3-0.1.2-cp35-cp35m-manylinux1_x86_64.whl (756.2 kB view details)

Uploaded CPython 3.5m

blake3-0.1.2-cp35-cp35m-macosx_10_7_x86_64.whl (160.8 kB view details)

Uploaded CPython 3.5m macOS 10.7+ x86-64

File details

Details for the file blake3-0.1.2.tar.gz.

File metadata

  • Download URL: blake3-0.1.2.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d50dde8500bce4d3bbe60265c0a911e4b2aac3e52940191ae2ffdaea3b347c28
MD5 d8393984ea4b81f94211eb4f9d6433dc
BLAKE2b-256 ca479cf2ffdf727f7c44579cda2f1e1f56b6331be8709b3b1a2b379947197850

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp38-none-win_amd64.whl.

File metadata

  • Download URL: blake3-0.1.2-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 119.2 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 57b9b019d84ffa27ed7b2280f301103b92a3527372d0532726e33d876841ba68
MD5 01939ee74ca35baad96736c0c60c61e1
BLAKE2b-256 02918e064421ad997fe9e39f70ff528a115742534d044a036c643090bd833c4e

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp38-none-win32.whl.

File metadata

  • Download URL: blake3-0.1.2-cp38-none-win32.whl
  • Upload date:
  • Size: 117.6 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp38-none-win32.whl
Algorithm Hash digest
SHA256 84b04cc412cb294c1fedb9ac1d5177d3bde10b0bfe09aedde32667e0a062e748
MD5 8e659bee993c05bcb4f0ac521b2379d4
BLAKE2b-256 f4bd408c052df4c6d93dac28e3d3d274ca1672dc2e4eae79f8e6c308783d61aa

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: blake3-0.1.2-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 755.6 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 02252dd033ae79da164a4e96693f9bf95db62df70199b9274c9ab073b49c2ddb
MD5 77f0b18212b0cddd0ec70ee589518e10
BLAKE2b-256 77ad8ef65bd3bd7461b32d09eb3499c6654e51251789d9bcfcc7534f20a16abc

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: blake3-0.1.2-cp38-cp38-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 160.2 kB
  • Tags: CPython 3.8, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 62b8b944c31b95e675eb2b0ea88436bee05f2a5be4622745eebb19cf941691f8
MD5 8a6f406dda7666e66c0058e7fd9e2a8c
BLAKE2b-256 8535165c566a0b285661c6086873787cfa2bbfaf418f14e6ae761d095c450b8b

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp37-none-win_amd64.whl.

File metadata

  • Download URL: blake3-0.1.2-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 119.2 kB
  • Tags: CPython 3.7, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 5706661188f2eae3d593ea1fbd94bdfd79d89aa6376c3edbf99c6364eebed623
MD5 e057c34abf2f6cf0851d964c726a3693
BLAKE2b-256 8496e9b992967ca559643390b7e145713bc2d4fe1132727b9af06e9fe34c3921

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp37-none-win32.whl.

File metadata

  • Download URL: blake3-0.1.2-cp37-none-win32.whl
  • Upload date:
  • Size: 117.6 kB
  • Tags: CPython 3.7, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp37-none-win32.whl
Algorithm Hash digest
SHA256 20b43b3e58da0ebd873c002ad9d90ad022dc5012d4331f02844f8bda26130b46
MD5 0f4c09d1d9c17b27edb197eb278a10c0
BLAKE2b-256 4f436e71d19bd4e94e040ba4c63c161ba33c702dba0113e66a8e867d184a0438

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: blake3-0.1.2-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 755.5 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e111ef9220c9046cc433d1a2ff55d1c680d83c1e74cc89b8a81a46234a74e700
MD5 4974c8f0b0884faa5e0aacdbe946b535
BLAKE2b-256 d5e4cd0a27fbeb3209ce711944db5d30449c0975065066ab759af1e5daffc2d3

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: blake3-0.1.2-cp37-cp37m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 160.2 kB
  • Tags: CPython 3.7m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 b875fd51d3a2081ab1cb8974bada58d252dd756243383b8569ad06ab559971cd
MD5 13012494abb18cd6839982778602a655
BLAKE2b-256 4e3ef0d0bad9ea5e481b6343a3c8b3c2eb2897e9bcfd9927b92e3b8c49ddf7ef

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp36-none-win_amd64.whl.

File metadata

  • Download URL: blake3-0.1.2-cp36-none-win_amd64.whl
  • Upload date:
  • Size: 119.8 kB
  • Tags: CPython 3.6, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 164d3aed22d7734a28b6b782f23f65530117efab56c3704378a476bca8006864
MD5 f1f52697e84674f0479524317649503d
BLAKE2b-256 53a0c179775e13cc8f4021566dbc41c70cc5eec8d86da620735a2aebf80d9135

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp36-none-win32.whl.

File metadata

  • Download URL: blake3-0.1.2-cp36-none-win32.whl
  • Upload date:
  • Size: 118.2 kB
  • Tags: CPython 3.6, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp36-none-win32.whl
Algorithm Hash digest
SHA256 e3e0312a508f4f7791a4d5aba3c969b61018a714beb8e26e8058ecde348d19fd
MD5 e526ff64a8d20d29cfcf6d8b23ea81f2
BLAKE2b-256 b1fd021788cbc8042678c338cbb888d1d0959e1bb919bb6d76a1260757bfb1a5

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: blake3-0.1.2-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 756.3 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ac9431840ee55fcf9541450eac2d47c4074917f2eccf0a5b9054ffb39f377cca
MD5 d241962023f33275dfd9c7d083136e4e
BLAKE2b-256 9ca302a39d5065759ea0f611c77295cb6e21caa3afb201dc94cc1496f98e2658

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: blake3-0.1.2-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 160.9 kB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 22044df8864e604897a2add0b9b4965166c2c970e334dbad5aad3b4067cdcb92
MD5 b47f10ccf28e9db9cc7246bb4eca009a
BLAKE2b-256 0fb127831fed09044b9038d1b2422c0a7951283db7a27b219d44b0f4e06fcef6

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp35-none-win_amd64.whl.

File metadata

  • Download URL: blake3-0.1.2-cp35-none-win_amd64.whl
  • Upload date:
  • Size: 119.8 kB
  • Tags: CPython 3.5, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp35-none-win_amd64.whl
Algorithm Hash digest
SHA256 35f958210d5ca835f1118533379b0704a18e1ed4b8d94822b396cda5897f726b
MD5 1a5180fba6c8702c2f58fee7b48f969e
BLAKE2b-256 2825710e6ce98c932f37cf84a22166287131eb84add56ad6e930169962d9c095

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp35-none-win32.whl.

File metadata

  • Download URL: blake3-0.1.2-cp35-none-win32.whl
  • Upload date:
  • Size: 118.2 kB
  • Tags: CPython 3.5, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp35-none-win32.whl
Algorithm Hash digest
SHA256 7162450703181fadd9c2bd3851cf683e71df53281c1da03ca452db770675fc32
MD5 607833e4a48b21bacad8a7b173920a2e
BLAKE2b-256 19ae6e22071d5fb4498ae3640c2784567dbf419d85f9d3372e08e4c9c3da8315

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: blake3-0.1.2-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 756.2 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6c65202738ddbbe0b49311490aee3bf5fc85031f5c6a4aa4c687a2375724dc0d
MD5 f5092d6a4bd1962a6e68d278e497aeee
BLAKE2b-256 8eee6d9815219f25e1e2634daef588d4b9cd9788a4d7edeb8f116b7b9cabbe14

See more details on using hashes here.

File details

Details for the file blake3-0.1.2-cp35-cp35m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: blake3-0.1.2-cp35-cp35m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 160.8 kB
  • Tags: CPython 3.5m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for blake3-0.1.2-cp35-cp35m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 358d5cc5a1fe2502b69a3ddbfaddb2d0f9787e4ba57cdb6e6c83d52263c378a4
MD5 fff8906466500d78f7e0e01f6039af7c
BLAKE2b-256 2c73cf9fea8fe01c61660462de3b40a5a7978ab3fd3e5c59069c390517006904

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page