#!/usr/bin/env python3

def str_xor(data, key):
    for i in range(len(data)):
        data[i] ^= key[i % len(key)]
    return data

key  = bytearray(open('xorkey.bin', 'rb').read())

for i in range(len(key)):
    print(key)
    data = bytearray(open('tobexored.bin',  'rb').read())
    encoded = str_xor(data, key)
    open("9.xor"+str(i), "wb").write(encoded)
    key = key[:-1]
