Source code for construe.cloud.signature
"""
Computes the signature of downloaded files for hash verification.
"""
import hashlib
[docs]
def sha256sum(path, blocksize=65536):
"""
Computes the SHA256 signature of a file to verify that the file has not
been modified in transit and that it is the correct version of the data.
"""
sig = hashlib.sha256()
with open(path, "rb") as f:
buf = f.read(blocksize)
while len(buf) > 0:
sig.update(buf)
buf = f.read(blocksize)
return sig.hexdigest()