Skip to main content

Python bindings for the Rust blake3 crate

Project description

blake3-py Actions Status PyPI version

Python bindings for the official Rust implementation of BLAKE3, based on PyO3. These bindings expose all the features of BLAKE3, including extendable output, keying, and multithreading. The basic API matches that of Python's standard hashlib module.

Examples

from blake3 import blake3

# Hash some input all at once. The input can be bytes, a bytearray, or a memoryview.
hash1 = blake3(b"foobarbaz").digest()

# Hash the same input incrementally.
hasher = blake3()
hasher.update(b"foo")
hasher.update(b"bar")
hasher.update(b"baz")
hash2 = hasher.digest()
assert hash1 == hash2

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

# Use the keyed hashing mode, which takes a 32-byte key.
import secrets
random_key = secrets.token_bytes(32)
message = b"a message to authenticate"
mac = blake3(message, key=random_key).digest()

# Use the key derivation mode, which takes a context string. Context strings
# should be hardcoded, globally unique, and application-specific.
context = "blake3-py 2020-03-04 11:13:10 example context"
key_material = b"usually at least 32 random bytes, not a password"
derived_key = blake3(key_material, derive_key_context=context).digest()

# Extendable output. The default digest size is 32 bytes.
extended = blake3(b"foo").digest(length=100)
assert extended[:32] == blake3(b"foo").digest()
assert extended[75:100] == blake3(b"foo").digest(length=25, seek=75)

# Hash a large input using multiple threads. Note that this can be slower for
# inputs shorter than ~1 MB, and it's a good idea to benchmark it for your use
# case on your platform.
large_input = bytearray(1_000_000)
hash_single = blake3(large_input).digest()
hash_two = blake3(large_input, max_threads=2).digest()
hash_many = blake3(large_input, max_threads=blake3.AUTO).digest()
assert hash_single == hash_two == hash_many

# Copy a hasher that has already accepted some input.
hasher1 = blake3(b"foo")
hasher2 = hasher1.copy()
hasher1.update(b"bar")
hasher2.update(b"baz")
assert hasher1.digest() == blake3(b"foobar").digest()
assert hasher2.digest() == blake3(b"foobaz").digest()

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. But if you're building the source distribution, or if a binary wheel isn't available for your environment, you'll need to install the Rust toolchain.

C Bindings

Experimental bindings for the official BLAKE3 C implementation are available in the c_impl directory. These will probably not be published on PyPI, and most applications should prefer the Rust-based bindings. But if you can't depend on the Rust toolchain, and you're on some platform that this project doesn't provide binary wheels for, the C-based bindings might be an alternative.

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

Uploaded Source

Built Distributions

blake3-0.3.2-cp311-none-win_amd64.whl (203.2 kB view details)

Uploaded CPython 3.11 Windows x86-64

blake3-0.3.2-cp311-none-win32.whl (221.0 kB view details)

Uploaded CPython 3.11 Windows x86

blake3-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

blake3-0.3.2-cp311-cp311-macosx_11_0_arm64.whl (326.6 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

blake3-0.3.2-cp311-cp311-macosx_10_7_x86_64.whl (352.4 kB view details)

Uploaded CPython 3.11 macOS 10.7+ x86-64

blake3-0.3.2-cp310-none-win_amd64.whl (203.2 kB view details)

Uploaded CPython 3.10 Windows x86-64

blake3-0.3.2-cp310-none-win32.whl (221.0 kB view details)

Uploaded CPython 3.10 Windows x86

blake3-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

blake3-0.3.2-cp310-cp310-macosx_11_0_arm64.whl (326.6 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

blake3-0.3.2-cp310-cp310-macosx_10_7_x86_64.whl (352.4 kB view details)

Uploaded CPython 3.10 macOS 10.7+ x86-64

blake3-0.3.2-cp39-none-win_amd64.whl (203.2 kB view details)

Uploaded CPython 3.9 Windows x86-64

blake3-0.3.2-cp39-none-win32.whl (221.1 kB view details)

Uploaded CPython 3.9 Windows x86

blake3-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

blake3-0.3.2-cp39-cp39-macosx_11_0_arm64.whl (326.6 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

blake3-0.3.2-cp39-cp39-macosx_10_7_x86_64.whl (352.6 kB view details)

Uploaded CPython 3.9 macOS 10.7+ x86-64

blake3-0.3.2-cp38-none-win_amd64.whl (203.3 kB view details)

Uploaded CPython 3.8 Windows x86-64

blake3-0.3.2-cp38-none-win32.whl (220.9 kB view details)

Uploaded CPython 3.8 Windows x86

blake3-0.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

blake3-0.3.2-cp38-cp38-macosx_11_0_arm64.whl (326.7 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

blake3-0.3.2-cp38-cp38-macosx_10_7_x86_64.whl (352.5 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

blake3-0.3.2-cp37-none-win_amd64.whl (203.3 kB view details)

Uploaded CPython 3.7 Windows x86-64

blake3-0.3.2-cp37-none-win32.whl (220.9 kB view details)

Uploaded CPython 3.7 Windows x86

blake3-0.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

blake3-0.3.2-cp37-cp37m-macosx_10_7_x86_64.whl (352.4 kB view details)

Uploaded CPython 3.7m macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: blake3-0.3.2.tar.gz
  • Upload date:
  • Size: 116.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.15

File hashes

Hashes for blake3-0.3.2.tar.gz
Algorithm Hash digest
SHA256 6d23147940d789cf0d482638344dc949f781b620e070bc1c00eb55a9e8d37cc7
MD5 54d2dd9d7ffbd360472ae5a7b88881f5
BLAKE2b-256 749d646d7e8d957f81cb96531bd8d2b0928b9b2b4795e45791d3e980df44e456

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp311-none-win_amd64.whl.

File metadata

  • Download URL: blake3-0.3.2-cp311-none-win_amd64.whl
  • Upload date:
  • Size: 203.2 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.15

File hashes

Hashes for blake3-0.3.2-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 867cf2c3c3501ecd6711940854cf3e37f16ca963481cc7d69bac4a478871e04f
MD5 1fe79fd06e962e31ba83f6d5edc223e1
BLAKE2b-256 d79de425414fcbf26766424bdbecf0f30d9bbb4b198e1923d235eddba33ac455

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp311-none-win32.whl.

File metadata

  • Download URL: blake3-0.3.2-cp311-none-win32.whl
  • Upload date:
  • Size: 221.0 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.15

File hashes

Hashes for blake3-0.3.2-cp311-none-win32.whl
Algorithm Hash digest
SHA256 9ddbd5bc07ba9ba0ed7364870d1e5740adf16c15609fdf2a3198e1d74baa91c3
MD5 36641cd61169817aebf75ecd3da9bf29
BLAKE2b-256 1802babc8b1f8c30b71ac034cf8dadaf3e199a650b93caab50b0292f9cbefb75

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for blake3-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0e01667914ac998285e5c392bc2652ba046178ce5415b00b59cd70ee4d4d795a
MD5 497ff04ab2d4eba748d5d5166b877c21
BLAKE2b-256 5c1767002e0f9a9271a2c29dcff7cbc76e37ced44859f2d349e7a80d104b0fab

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for blake3-0.3.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 02c268eb0ea105add0cd468e727f44aec8140e1d77bd589d733f0250fea810fc
MD5 a77caead4c9527b4215e5b342276a43c
BLAKE2b-256 789aedc9e56b4ac5d347c65d8c424b32467853f77ec5b78bd9dbf21d52a08130

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp311-cp311-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for blake3-0.3.2-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 b17b5b68aeb39b4ccdb63ee67baf71542142eae143387729fb9ae7691bf49fa1
MD5 2471f7be2db292ddeb33ab1e7677531d
BLAKE2b-256 f75bb9545e62cdeb928df792450bc79639d4ea9c04d196288cd33fb78cab2ae9

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp310-none-win_amd64.whl.

File metadata

  • Download URL: blake3-0.3.2-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 203.2 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.15

File hashes

Hashes for blake3-0.3.2-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 2b350363f39dac89271614be035fb1e403a7c2d947f7417fb2b41002e2ba5d9b
MD5 1963012816db789e391ea59355c2c1b4
BLAKE2b-256 b224d339b086f7bb5fe28e1bbb31db6b2029c442d26145d97880ab7ba4813c14

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp310-none-win32.whl.

File metadata

  • Download URL: blake3-0.3.2-cp310-none-win32.whl
  • Upload date:
  • Size: 221.0 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.15

File hashes

Hashes for blake3-0.3.2-cp310-none-win32.whl
Algorithm Hash digest
SHA256 1f2e718945dc8055d38456de3c7534521e69b550c16b7ec329ee0e7f02d90bca
MD5 d81f0df9e93a727fd7d3638afecc22e6
BLAKE2b-256 a9973c17bf737daa8e526c05477302674f3fec834c542f3f3f6cbc016a8cc905

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for blake3-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 31fd076d5c8c026fb688962e087b6e66bbd351ab8720ff6a90394654b4d2cb9e
MD5 a7d8694221004961cb7ffcc4dcb06dc4
BLAKE2b-256 3bcccfa9f8c9ac9fbc06c2c51b6d3d2fcf7e5bd53bbbca68e70d59b7f4c3b3c6

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for blake3-0.3.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e32372dc437fc4a74f1378d95e4808adc9ec7f251fcf0d89ed7cec1a1db660c9
MD5 1547fca02d8b605501da873893871d99
BLAKE2b-256 272a8036f9caafaa890af9ec0f6718ff04561f55c7933fcd1a20bcafa7f6b87c

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp310-cp310-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for blake3-0.3.2-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 878b0ba53584668bb260a8ccc0028c828d767fc8b64c69c3817371cea46f7611
MD5 30b66b49a23bcc718cff13b4a06dcc3a
BLAKE2b-256 2b4769e896617773368f5a57658f767b5fec048b8565fb1b939fcff5b9b73556

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp39-none-win_amd64.whl.

File metadata

  • Download URL: blake3-0.3.2-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 203.2 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.15

File hashes

Hashes for blake3-0.3.2-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 35dc5902a88bd0c3ff3d9f4b27a25f8b36ea1cc169f95b5fd5af5e530b446c62
MD5 2f7b1aec3a9f634357f1c0ed5459da51
BLAKE2b-256 ef9f92d436a8a6202bb05e039863286d8e48be101ab4a9307a7cd8558b6cbbf7

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp39-none-win32.whl.

File metadata

  • Download URL: blake3-0.3.2-cp39-none-win32.whl
  • Upload date:
  • Size: 221.1 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.15

File hashes

Hashes for blake3-0.3.2-cp39-none-win32.whl
Algorithm Hash digest
SHA256 51c1bf696cfcc3f117087a9eb774b9ab6fede3aac1972d42bc1d073d7a1a81c9
MD5 fc1f19fb7c976df5947fc0b154489c7f
BLAKE2b-256 79b31fe9fd7a065368442ac7c6d3a8413c0af4ceaff82c338e1fb3a08aef86a1

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for blake3-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6e743bb2cb3f3fcb79a1f2b4247744bc697983898c2053770b1905fa3930fbcf
MD5 ce9e0fba97476ff8189d7e35edc440c8
BLAKE2b-256 1b85b5006f20dc569487b5ea5a9298ad9e678b226a4495892f396c31506bb99d

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for blake3-0.3.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a53043fee1be798bea421d4bf6231dd3419c1d42dda7bae8a3c0551643ec456b
MD5 76484252b06f64dc901c5084e367f110
BLAKE2b-256 c9000b807ff3d64aefdcf90bdd3f2e1841215877022792fd518048db05378448

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for blake3-0.3.2-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 c75fc0c05f6f200076c1fcf22e1d5c7f12542f7c1a6fcc4b3665621990d9d98d
MD5 4f68989002d345e5142b9eaf18596905
BLAKE2b-256 141c2d0a5c42bbc1e5e28d5de87432e1b3c7f37619f8b7388c391980e52defd3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.3.2-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 203.3 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.15

File hashes

Hashes for blake3-0.3.2-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 e0c8d1f04eb1b539fd35fa7dda9a4113a12b979bfff6d058356905c143a47a98
MD5 f0f279cf0721437f4e9832639c129740
BLAKE2b-256 df95b77f37e59860274fe7b7d1c2f9e78bb845d924862d5aa9c2789bc1600863

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.3.2-cp38-none-win32.whl
  • Upload date:
  • Size: 220.9 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.15

File hashes

Hashes for blake3-0.3.2-cp38-none-win32.whl
Algorithm Hash digest
SHA256 2c5561e2b7a9d7504c8e8226fe70c0448f6400bb23f9f6f3f01f95deeb60e4e1
MD5 fce3d02a1c4db62fcdede04ef4d71f39
BLAKE2b-256 5f5a392aa4799a80ff2d615dfdce8e510d303080360734b3e964fb7f5e63edd4

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for blake3-0.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dcfda8438e03483b6f7bb7887bb548d5137ca5def1d8311cf79672bc053aed5d
MD5 c07515cb264ff4316b5f6141ecda111d
BLAKE2b-256 effe160f06d3ca8656d1b817b7b74e2df4790db9abe5070449808ef9b8589efa

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for blake3-0.3.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bec05e5119ddedc50c6ca0cff8737ac9db72bd6b02e554f3ecca8bb53a517366
MD5 10bce152a1e49c2c280e304ed36bd2cc
BLAKE2b-256 4f5d69be33da9b339b2a6a91a8bef4a3630d5208b6b260d6b37ed8011b5ddac9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for blake3-0.3.2-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 33ed2b82165371208074d5875c389ea45efd092c3bfa9acdde998488613f366f
MD5 9d7cedc37542de1241085bbcd598487d
BLAKE2b-256 3968fa51504c869fcd3050c577bdc57a42ad12d403de77a3b920fb23fb67ec5a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.3.2-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 203.3 kB
  • Tags: CPython 3.7, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.15

File hashes

Hashes for blake3-0.3.2-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 3cec44d008a9e3154dff22151c2b286b9c3e4b70ac5cfeacde89ab30a7ad1490
MD5 af35edc7780dc86d8076df171101c164
BLAKE2b-256 cda6c94d219e4fa4b67e8e1986bd0568ec87ec0ac27f2333d6d234c75625bf69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blake3-0.3.2-cp37-none-win32.whl
  • Upload date:
  • Size: 220.9 kB
  • Tags: CPython 3.7, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.15

File hashes

Hashes for blake3-0.3.2-cp37-none-win32.whl
Algorithm Hash digest
SHA256 9d88ce0cf3df376b81ccc46872c457deb94407978675f16c584bba893043ae09
MD5 df91650c8e2206b67ea5212fd19def52
BLAKE2b-256 55b864005e49103a19acb5bc5d2990a602026eaa8ffa6da1547b40d8b9e1d473

See more details on using hashes here.

File details

Details for the file blake3-0.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for blake3-0.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 165582b654100616c885bb883a4416193bb6ae63578b2d4a9861d39f53d1348c
MD5 1996efd8eee9c9b70079be2efcad010b
BLAKE2b-256 2f399f08a649a804cd29ae417d27356ce42896acdf137af72a8d12d22870dce1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for blake3-0.3.2-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 7a7698c5e50535b0f181acf7b466321e442a0e10b515cda0a6aadf8330d40d52
MD5 72d970a21989f581f9b59ae964c9e8de
BLAKE2b-256 9d515c1a1853944aa2dc9f7218e904684430d85c989fca9aa71f774e1812a376

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