import hashlib


def get_bytes_hash(bytes, hash_function=hashlib.md5, chunk_size=4096):
    """
    Return hash of byte stream.

    Adapted from quantumSoup at https://stackoverflow.com/a/3431838.
    """
    hash = hash_function()
    for chunk in iter(lambda: bytes.read(chunk_size), b""):
        hash.update(chunk)

    return hash