pint.utils.compute_hash

pint.utils.compute_hash(filename)[source]

Compute a unique hash of a file.

This is designed to keep around to detect changes, not to be cryptographically robust. It uses the SHA256 algorithm, which is known to be vulnerable to a length-extension attack.

Parameters:

f (str or Path or file-like) – The source of input. If file-like, it should return bytes not str - that is, the file should be opened in binary mode.

Returns:

A cryptographic hash of the input.

Return type:

bytes