httk.core.digests

Compute deterministic SHA-256 digests for files and directory trees.

Hash tree paths and entries in sorted order without following symlinks.

Functions

sha256_file(path)

Return the lowercase SHA-256 digest of one regular file.

tree_digest(path, *[, skip, exclude])

Hash a tree without following symlinks.

Module Contents

httk.core.digests.sha256_file(path)[source]

Return the lowercase SHA-256 digest of one regular file.

Parameters:

path (pathlib.Path) – Regular file to hash.

Returns:

Lowercase SHA-256 digest.

Return type:

str

httk.core.digests.tree_digest(path, *, skip=None, exclude=None)[source]

Hash a tree without following symlinks.

skip names top-level entries to leave out of the digest entirely. exclude names relative POSIX paths to leave out; excluding a directory also leaves out its descendants.

Parameters:
Returns:

Lowercase SHA-256 digest.

Raises:

ValueError – If the tree contains a symlink or special file.

Return type:

str