import hashlib


def _sha256_hash(filename, blocksize=65536):
    """Hash the contents of an open file handle with SHA256"""
    hash_obj = hashlib.sha256()

    with open(filename, "rb") as file_obj:
        block = file_obj.read(blocksize)
        while block:
            hash_obj.update(block)
            block = file_obj.read(blocksize)

    return hash_obj.hexdigest()