def xor(data, key):
    l = len(key)
return bytearray(data[i] ^ key[i % l] for i in range(0, len(data)))
data = bytearray(open('myfile.bin', 'rb').read())
key = bytearray([42, 43, 44, 94, 37, 68])
XORing file with multi-byte key