BLAKE2
BLAKE2 digest algorithms.
BLAKE2B and BLAKE2S take a keyword-only digest_size of 1–64 and 1–32 bytes (default: the maximum). All sequential variants accept key (up to 64/32 bytes; RFC 7693 keyed mode, a MAC), salt and person (up to 16/8 bytes).
BLAKE2BP and BLAKE2SP are the 4-way and 8-way parallel variants from blake2b_simd/blake2s_simd. They accept a digest_size option.
Example
from oxcrypto.hash.blake2 import BLAKE2
algorithm = BLAKE2.BLAKE2B256
digest = algorithm.digest(b"hello")
assert digest == algorithm.digest_chunks([b"he", b"llo"])
hasher = algorithm.new()
hasher.update(b"he")
hasher.update(b"llo")
assert hasher.digest() == digest
print(digest.hex())Variants
BLAKE2.BLAKE2B128BLAKE2.BLAKE2B256BLAKE2.BLAKE2B512BLAKE2.BLAKE2S128BLAKE2.BLAKE2S256BLAKE2.BLAKE2BBLAKE2.BLAKE2SBLAKE2.BLAKE2BPBLAKE2.BLAKE2SP
Methods
digest(self, data: bytes, /, *, digest_size: int | None=None, key: bytes=b'', salt: bytes=b'', person: bytes=b'') -> bytes
digest_chunks(self, chunks: Iterable[bytes], /, *, digest_size: int | None=None, key: bytes=b'', salt: bytes=b'', person: bytes=b'') -> bytes
new(self, *, digest_size: int | None=None, key: bytes=b'', salt: bytes=b'', person: bytes=b'') -> Hasher