Checksum API
pathapi.checksum
__all__ = ['md5', 'native', 'sha256', 'stream']
module-attribute
md5(path, chunk_size=65536)
Calculate MD5 checksum of the file at path.
Source code in src/pathapi/checksum.py
33 34 35 | |
native(path, algorithm='md5')
Try path's backend-native NativeChecksum.checksum() (see
protocols/checksum.py); return None if path doesn't implement the
protocol at all, or if it does but can't produce algorithm (raises
NotImplementedError -- the protocol's documented contract for
"unsupported", never a wrong-algorithm value). Never raises for either
of those two cases; any other exception the backend raises propagates.
Source code in src/pathapi/checksum.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
sha256(path, chunk_size=65536)
Calculate SHA-256 checksum of the file at path.
Source code in src/pathapi/checksum.py
38 39 40 | |
stream(path, algorithm='md5', chunk_size=65536)
Streaming checksum for an arbitrary hashlib algorithm name (the
generic form of md5/sha256 above, used where the algorithm is a
runtime parameter rather than fixed at the call site -- e.g.
PathSyncer's streaming fallback, which must match whatever algorithm
a native checksum attempt was made under).
The digest compares content; it is not a security use, so it is created
with usedforsecurity=False -- on a FIPS-mode host hashlib.md5()
otherwise raises ValueError.
Source code in src/pathapi/checksum.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |