Hash functions

Interface to hashing algorithms.

pyflocker.ciphers.interfaces.Hash.algorithms_available(backend: Backends | None = None) set[str][source]

Returns all available hashes supported by backend.

pyflocker.ciphers.interfaces.Hash.new(hashname: str, data: bytes | None = None, digest_size: int | None = None, *, custom: bytes | None = None, key: bytes | None = None, backend: _Backends | None = None) BaseHash[source]

Instantiate a new hash instance hashname with initial data data (default is empty bytes). The Hash object created by this function can be used as the hash argument to OAEP and MGF1.

Parameters:
  • name – The name of the hash function.

  • data – The initial chunk of message to feed to hash.

  • digest_size – The length of the digest size. Must be supplied if the hash function supports it.

Keyword Arguments:
  • custom – A customization string. Can be supplied for hash functions that support domain separation.

  • key – A key that is used to compute the MAC. Can be supplied for hash functions that support working as cryptographic MAC.

  • backend – The backend to use. It must be a value from Backends.

Returns:

A Hash interface with the given hashing algorithm.

Raises:

KeyError – if the hashing function is not supported or invalid.