import random


def t05_SmallLengthChangingPuts(C, pks, crypto, server):
    """Randomly adds or deletes a small number of bytes from a file, and ensures
    data is correct."""
    alice = C("alice")
    data = "".join(chr(random.randint(0, 255)) for _ in range(10000))
    for _ in range(100):
        i = random.randint(0, len(data)-1)
        if random.randint(0, 1) == 0:
            insert = ("".join(chr(random.randint(0, 255)) for _ in
                              range(random.randint(1, 10))))
            data = data[:i] + insert + data[i:]
        else:
            data = data[:i] + data[i + random.randint(1, 10):]
        alice.upload("k", data)
    return float(alice.download("k") == data)