API Docs

class multihash.MultiHash(data=None, hashers=None)

A class which effeciently generates multiple hashes.

__init__(data=None, hashers=None)

Create a new MultiHash instance.

Parameters
property block_size

Return a dict of all the underlying block sizes.

Return type

Dict[str, int]

copy(*args, **kwargs)

Return a dictionary containing copies of all the hashers.

Return type

Dict[str, HasherType]

digest(*args, **kwargs)

Return a dictionary containing all the digests.

Return type

Dict[str, bytes]

property digest_size

Return a dict of all the underlying digest sizes.

Return type

Dict[str, int]

classmethod from_filepath(filepath, hashers=None, chunksize=128000000)

Instantiate a new MultiHash and hash a file located at some file path.

Parameters
  • filepath (PathLike) – A file path

  • hashers (Optional[Iterable[Union[HasherType, str]]]) – Instances of classes conforming to the hashlib.hash interface, or names of hashes appropriate for new()

  • chunksize (int) – How many bytes to read into RAM at once

Return type

MultiHash

classmethod from_stream(stream, hashers=None, chunksize=128000000)

Instantiate a new MultiHash and hash a .read()-able thing.

Parameters
  • stream (BinaryIO) – An object which implements .read()

  • hashers (Optional[Iterable[Union[HasherType, str]]]) – Instances of classes conforming to the hashlib.hash interface

  • chunksize (int) – How many bytes to read into RAM at once

Return type

MultiHash

property hashers

Return a set of all the contained “hashers”.

Return type

Set[HasherType]

hexdigest(*args, **kwargs)

Return a dictionary containing all the hexdigests.

Return type

Dict[str, str]

property name

Return a name for the MultiHash instance.

Return type

str

update(data)

Update all the underlying hashes with the supplied data.

Parameters

data (bytes) – The data to update the hashes with.

Return type

None