import hashlib


def _hash_file(filename, blocksize=65536):
    """Hashes the given file.

    :param filename: Path to file
    :returns: Hex digest of the md5 checksum

    """
    hasher = hashlib.md5()
    with open(filename, 'rb') as infile:
        buf = infile.read(blocksize)
        while len(buf) > 0:
            hasher.update(buf)
            buf = infile.read(blocksize)

    return hasher.hexdigest()