Package Cryptodome :: Package Hash :: Module keccak

Module keccak

Keccak family of cryptographic hash algorithms.

Keccak is the winning algorithm of the SHA-3 competition organized by NIST. What eventually became SHA-3 is a variant incompatible to Keccak, even though the security principles and margins remain the same.

If you are interested in writing SHA-3 compliant code, you must use the modules SHA3_224, SHA3_256, SHA3_384 or SHA3_512.

This module implements the Keccak hash functions for the 64 bit word length (b=1600) and the fixed digest sizes of 224, 256, 384 and 512 bits.

>>> from Cryptodome.Hash import keccak
>>>
>>> keccak_hash = keccak.new(digest_bits=512)
>>> keccak_hash.update(b'Some data')
>>> print keccak_hash.hexdigest()
Classes
  Keccak_Hash
Class that implements a Keccak hash
Functions
 
new(**kwargs)
Return a fresh instance of the hash object.
Variables
  __package__ = 'Cryptodome.Hash'
Function Details

new(**kwargs)

 
Return a fresh instance of the hash object.
Parameters:
  • data (byte string) - Optional. The very first chunk of the message to hash. It is equivalent to an early call to update().
  • digest_bytes (integer) - The size of the digest, in bytes (28, 32, 48, 64).
  • digest_bits (integer) - The size of the digest, in bits (224, 256, 384, 512).
  • 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 Keccak_Hash object