import hashlib


def hash_file(filename, algo="sha1", bsize=65536):
    """
    This helper function is aimed to hash a file.

    :param path: name of the file to be hashed
    :param algo: hashing algorithm (among those implemented in hashlib)
    :param bsize: block size
    """
    h = getattr(hashlib, algo)()
    with open(filename, 'rb') as f:
        b = f.read(bsize)
        while len(b) > 0:
            h.update(b)
            b = f.read(bsize)
    return h.hexdigest()