import hashlib


def _hashfile(filename):
    """Calculates the sha256 of a file

    :param filename: path to the file to sum
    :type filename: str
    :returns: digest in hexadecimal
    :rtype: str
    """

    hasher = hashlib.sha256()
    with open(filename, 'rb') as f:
        for chunk in iter(lambda: f.read(4096), b''):
            hasher.update(chunk)
    return hasher.hexdigest()