New hash objects are created by calling constructor functions:
These functions return the corresponding hash objects for calculating BLAKE2b or BLAKE2s. They optionally take these general parameters:
The following table shows limits for general parameters (in bytes):
Hash | digest_size | len(key) | len(salt) | len(person) |
---|---|---|---|---|
BLAKE2b | 64 | 64 | 16 | 16 |
BLAKE2s | 32 | 32 | 8 | 8 |
Note
BLAKE2 specification defines constant lengths for salt and personalization parameters, however, for convenience, this implementation accepts byte strings of any size up to the specified length. If the length of the parameter is less than specified, it is padded with zeros, thus, for example, b'salt' and b'salt\x00' is the same value. (This is not the case for key.)
These sizes are available as module constants described below.
Constructor functions also accept the following tree hashing parameters:
See section 2.10 in BLAKE2 specification for comprehensive review of tree hashing.
Hash objects have the following attributes and methods:
The size of the resulting digest in bytes. This is the value given to hash object constructor in digest_size argument.
The internal block size of the hash algorithm in bytes.
Update the hash object with the object, which must be interpretable as buffer of bytes
Note
For better multithreading performance, the Python GIL is released for data larger than 2047 bytes at hash object creation or on update to allow other threads to run.
Return the digest of the data so far.
Like digest() except the digest is returned as a string of double length, containing only hexadecimal digits.
Return a copy of the hash object.
Salt length (maximum length accepted by constructors).
Personalization string length (maximum length accepted by constructors).
Maximum key size.
Maximum digest size that the hash function can output.