import hashlib


def hash_large_file(file, chunk_size=1280000000, digest=True):
    """fast hashing of file

    see https://stackoverflow.com/a/1131238/5172579
    """

    with open(file, "rb") as f:
        file_hash = hashlib.sha1()
        chunk = f.read(chunk_size)
        while chunk:
            file_hash.update(chunk)
            chunk = f.read(chunk_size)

    if digest:
        return file_hash.hexdigest()
    return file_hash