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 will 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.

Soundness

There are some fundamental questions about whether these bindings can be sound. Like the Python standard library's hash implementations, in order to avoid blocking other threads during a potentially expensive call to update(), we release the GIL. But that opens up the possibility that another thread might mutate, say, the bytearray we're hashing, while the Rust code is treating it as a &[u8]. That violates Rust's aliasing guarantees and is technically unsound. However, no Python hashing implementation that I'm aware of holds the GIL while it calls into native code. I need to get some expert opinions on this.

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

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.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distributions

blake3-0.1.1-cp38-none-win_amd64.whl (378.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

blake3-0.1.1-cp38-none-win32.whl (365.7 kB view details)

Uploaded CPython 3.8 Windows x86

blake3-0.1.1-cp38-cp38-manylinux1_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.8

blake3-0.1.1-cp38-cp38-macosx_10_7_x86_64.whl (544.6 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

blake3-0.1.1-cp37-none-win_amd64.whl (378.7 kB view details)

Uploaded CPython 3.7 Windows x86-64

blake3-0.1.1-cp37-none-win32.whl (365.8 kB view details)

Uploaded CPython 3.7 Windows x86

blake3-0.1.1-cp37-cp37m-manylinux1_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.7m

blake3-0.1.1-cp37-cp37m-macosx_10_7_x86_64.whl (544.7 kB view details)

Uploaded CPython 3.7m macOS 10.7+ x86-64

blake3-0.1.1-cp36-none-win_amd64.whl (379.4 kB view details)

Uploaded CPython 3.6 Windows x86-64

blake3-0.1.1-cp36-none-win32.whl (366.5 kB view details)

Uploaded CPython 3.6 Windows x86

blake3-0.1.1-cp36-cp36m-manylinux1_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.6m

blake3-0.1.1-cp36-cp36m-macosx_10_7_x86_64.whl (545.1 kB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

blake3-0.1.1-cp35-none-win_amd64.whl (379.4 kB view details)

Uploaded CPython 3.5 Windows x86-64

blake3-0.1.1-cp35-none-win32.whl (366.6 kB view details)

Uploaded CPython 3.5 Windows x86

blake3-0.1.1-cp35-cp35m-manylinux1_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.5m

blake3-0.1.1-cp35-cp35m-macosx_10_7_x86_64.whl (545.2 kB view details)

Uploaded CPython 3.5m macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: blake3-0.1.1.tar.gz
  • Upload date:
  • Size: 7.2 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.1.tar.gz
Algorithm Hash digest
SHA256 ac49a44a4fb1cdac1594d9ee3c018df3ba1ae619d1bba97176f7743068f42f1c
MD5 04205a40c4ec5c4282ea832229082efe
BLAKE2b-256 2ddca05a33955351ec90461bcd2a69fec8cb19438f7493a3f9fc2b18042cd61d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 378.7 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.1-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 3dace9320409a421db276a00152dbd2c570c0fee938575ef7ca431abeec09987
MD5 6d51ef63be90c2a2f0f0572cee75493f
BLAKE2b-256 9df9342fcea773955cc38e618b3a907d861825b7f77f797b58e703feea6b6abd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp38-none-win32.whl
  • Upload date:
  • Size: 365.7 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.1-cp38-none-win32.whl
Algorithm Hash digest
SHA256 2af7cf4834cb004a19e63c28ccdf6c6e24a25ba1bd6716717e70666924cc7325
MD5 af4a08252c7293162438f0bcc16a9dce
BLAKE2b-256 6e53cf3befd8d39a4169d362cfc96bbb7cacd73c78269996c5b22ad12fd4238e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.0 MB
  • 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.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3151a97d34544fe8a2831a015437b6887d010aa6a067f404269e3b85460232c3
MD5 e681468228100d0d1c56e38d9f76f6a9
BLAKE2b-256 fd12e5a19b293b96b8806b60f6b0f3ebdedbfcfbdca6ea4c204dfd5df5b2a418

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp38-cp38-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 544.6 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.1-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 abb63ed4166307f21a06d79ffc8ad955e55a9a9e179fe822f67465f5195291c4
MD5 04d9107ad1b5f00968c24216c6b99cf2
BLAKE2b-256 9f9a5267f0e0df7389f5207480e53b9530d2af8e627877d83add3336e0f34731

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 378.7 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.1-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 b45e00a330056c1eea037ce8d8141f2a52e73bff432d1340c3ece4e41bb89f7a
MD5 ed10755c9dc60c838e39d5a791688126
BLAKE2b-256 0b2649b8854ee54ec1fd68bce659364bbf44fdacb24b8696834fa993d33f8dfb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp37-none-win32.whl
  • Upload date:
  • Size: 365.8 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.1-cp37-none-win32.whl
Algorithm Hash digest
SHA256 cd7fecfbf1f04a3f361a31297ad429b52eabda4b65797eadf0665569f44d0781
MD5 6f4c028f65c0b8cd3e73842fd11e8b8f
BLAKE2b-256 9c7c08624ef785413c9da5632920076fb67b48dc0ac3bac3e07809e5536c048e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.0 MB
  • 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.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f63c1f3a4de18fc679538f1de209f2ce016e711769073e8f86762cbf48d96c5d
MD5 f34fcd0e67539d9e86ec36094954ee34
BLAKE2b-256 df4ad3ddb40b0f57f38640c894cbd47012f5dce33c3978b1e5febc4d4ef1c270

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp37-cp37m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 544.7 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.1-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 5072bb2252f7cc75acc04f97b6a8e47550662f16438daae293e9fac35d4b4bfc
MD5 1089485c3b8619fdf7d304cfcaa5cae9
BLAKE2b-256 652c1873978f2f455f3175182096a0b07cba4c126419a3ad6ae6c5d6a03bab84

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp36-none-win_amd64.whl
  • Upload date:
  • Size: 379.4 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.1-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 388a404b0f6131ab4feac41cd9095daacadb779503369c78010625d8a16b39d4
MD5 97ea53c70f1c66f1ad6ebe294235cd23
BLAKE2b-256 5ca899b1016874118e0a32fdab0ef1ca232e596309e8ed212a0396066d74731a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp36-none-win32.whl
  • Upload date:
  • Size: 366.5 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.1-cp36-none-win32.whl
Algorithm Hash digest
SHA256 ee7099705c0d12c2d5e22936eb09545083682f6b29abb0ea71778d1da1d1c6ca
MD5 c8d5cd786af95ca23ffea8cafc0c6707
BLAKE2b-256 c759284bf94d70f1284fea231e129ece82af6a729415f3ebb7fe0f5fdc1a12a3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.0 MB
  • 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.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 85aa65f6f602105182a9c39e6f9797ee447a07f66a727da122ba929b13a4cd1b
MD5 f99c0348e70433dd7ee0c06b33fc0531
BLAKE2b-256 f13193f7ad590d71c64be358bccd1b6012c3070695dcd81380677511bbeccbec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 545.1 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.1-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 b8fe4883cee5b468ae1bae8c7f5fc7be5063b1cde5988801fb2d5348cd508a51
MD5 28485b592a578029f8cae0631e9a5a0f
BLAKE2b-256 02a965e4ad357084cfa9fee012a0f46880e837f1610a7845ae8f77ab1e23951d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp35-none-win_amd64.whl
  • Upload date:
  • Size: 379.4 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.1-cp35-none-win_amd64.whl
Algorithm Hash digest
SHA256 461cb5986153a6ba0a8303bf11e073f41e456d22f0e5453f86157f7e1142f536
MD5 000556b3dea0ac7bca19a291f104993e
BLAKE2b-256 00875ed45466462064ca9769d9b700af8593f6a6df09a09fb90e043173b0d3f6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp35-none-win32.whl
  • Upload date:
  • Size: 366.6 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.1-cp35-none-win32.whl
Algorithm Hash digest
SHA256 3ebe617d4018f611cf8d9b7bd92e3c3a7b759fd4a2edcb73b3752d452814b3b3
MD5 4a423a421b01506e5c037db46191e205
BLAKE2b-256 1d8e13bf268d1f43e759422b6e4fe5bbf26b77ccd8d57f1338575dd5e173c0dc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.0 MB
  • 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.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 682e7761ab1081b026339639c80ca23d7d02d048a20624cb0e4cb55522b2606f
MD5 a194164d0c4499409b788d12816123eb
BLAKE2b-256 61a53f7f359a8b5740cecd7f25f93043888aa6f1c9ad3c885c2c0fca8e9069fc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.1.1-cp35-cp35m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 545.2 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.1-cp35-cp35m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 b3b1c748ba8ff6a8dcc3c408bb6a28dd86ed70dbe16461a7fd199576a9d26385
MD5 84c4be87588c64fddf575bdf63f665ae
BLAKE2b-256 a3f850b3e2234d1af4ddfc8f403fe367a11831d51ead9d275e1d4ee3a323f3b9

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