import hashlib


def file_hash(file: str, blocksize=4096):
    """Return hex digest for the input `file` in chunks of `blocksize`"""
    sha = hashlib.sha256()
    with open(file, 'rb') as fp:
        while 1:
            data = fp.read(blocksize)
            if data:
                sha.update(data)
            else:
                break
    return sha.hexdigest()