Keccak is a family of cryptographic hash algorithms that won the SHA-3 competition organized by NIST. What eventually became SHA-3 (FIPS 202) is a slight variant: though incompatible to Keccak, the security principles and margins remain the same.
This module implements the Keccak hash functions for the 64 bit word
b=1600) and the fixed digest sizes of 224, 256, 384 and 512 bits.
This is an example:
>>> from Crypto.Hash import keccak >>> >>> keccak_hash = keccak.new(digest_bits=512) >>> keccak_hash.update(b'Some data') >>> print keccak_hash.hexdigest()
Keccak_Hash(data, digest_bytes, update_after_digest)¶
A Keccak hash object. Do not instantiate directly. Use the
Variables: digest_size (integer) – the size in bytes of the resulting hash
Return the binary (non-printable) digest of the message that has been hashed so far.
Returns: The hash digest, computed over the data processed so far. Binary form. Return type: byte string
Return the printable digest of the message that has been hashed so far.
Returns: The hash digest, computed over the data processed so far. Hexadecimal encoded. Return type: string
Create a fresh Keccak hash object.
Continue hashing of a message by consuming the next chunk of data.
Parameters: data (byte string/byte array/memoryview) – The next chunk of the message being hashed.
Create a new hash object.
- data (bytes/bytearray/memoryview) – The very first chunk of the message to hash.
It is equivalent to an early call to
- 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) – Whether
Keccak.digest()can be followed by another
- data (bytes/bytearray/memoryview) – The very first chunk of the message to hash. It is equivalent to an early call to