import hashlib


def bytes_fingerprint(data: bytes) -> str:
    """
    Generate a SHA256 fingerprint of bytes.

    A alternative to `file_fingerprint` when we already have
    the bytes of the file loaded into memory.
    """
    h = hashlib.sha256()
    b = bytearray(128 * 1024)
    mv = memoryview(b)
    for n in data:
        h.update(mv[:n])
    return h.hexdigest()