Package Cryptodome :: Package Hash :: Module BLAKE2s

Module BLAKE2s

BLAKE2s cryptographic hash algorithm.

BLAKE2s is an optimized variant of BLAKE, one of the SHA-3 candidates that made it to the final round of the NIST hash competition.

The algorithm uses 32 bit words, and it therefore works best on 32-bit platforms. The digest size ranges from 8 to 256 bits.

>>> from Cryptodome.Hash import BLAKE2s
>>>
>>> h_obj = BLAKE2s.new(digest_bits=256)
>>> h_obj.update(b'Some data')
>>> print h_obj.hexdigest()

Optionally, BLAKE2s can work as a cryptographic MAC when initialized with a secret key.

>>> from Cryptodome.Hash import BLAKE2s
>>>
>>> mac = BLAKE2s.new(digest_bits=128, key=b'secret')
>>> mac.update(b'Some data')
>>> print mac.hexdigest()
Classes
  BLAKE2s_Hash
Class that implements a BLAKE2s hash
Functions
 
new(**kwargs)
Return a new instance of a BLAKE2s hash object.
Function Details

new(**kwargs)

 
Return a new instance of a BLAKE2s hash object.
Parameters:
  • data (byte string) - The very first chunk of the message to hash. It is equivalent to an early call to BLAKE2s_Hash.update().
  • digest_bytes (integer) - The size of the digest, in bytes (1 to 32).
  • digest_bits (integer) - The size of the digest, in bits (8 to 256, in steps of 8).
  • key (byte string) - The key to use to compute the MAC (1 to 32 bytes). If not specified, no key will be used.
  • update_after_digest (boolean) - Optional. By default, a hash object cannot be updated anymore after the digest is computed. When this flag is True, such check is no longer enforced.
Returns:
A BLAKE2s_Hash object