Skip to content

salvus.flow.acta.hashing

salvus.flow.acta.hashing salvus flow acta hashing

BLAKE3 hashing for content, cache keys, and file identities.

Functions

content_digest()

def content_digest(data: bytes) -> str: ...

Return the hex digest of some bytes.

Parameters
  • data bytes — The bytes to hash.
Returns str — The 64-character lowercase hex digest.

hash_file()

def hash_file(path: pathlib.Path | str, chunk_size: int = 1048576) -> str: ...

Return the hex digest of a file’s contents.

Use memory mapping when available, otherwise read in blocks.

Parameters
  • path pathlib.Path | str — The file to hash.
  • chunk_size int = 1048576 — Bytes to read per iteration, if the fallback is used. Ignored on the mapped path, which does not chunk.
Returns str — The 64-character lowercase hex digest of the file’s bytes.

new_hasher()

def new_hasher(threaded: bool = False) -> blake3: ...

Return a fresh incremental hasher.

Parameters
  • threaded bool = False — Whether to hash across all cores. The digest is the same either way; only the speed differs.
Returns blake3 — A hasher with update and hexdigest.