with open("test_known.txt") as f:
with open("test.txt", 'rb') as e:
i,j = 0,0
e.seek(28)
output = ""
pad = [0,0,0,0,0,0,0,0]
for char in f.read():
if j == 0:
char2 = e.read(1)
pad[i] = ord(char) ^ ord(char2)
output += chr(pad[i] ^ ord(char2))
else:
output += chr(pad[i] ^ ord(e.read(1)))
i += 1
if i % 8 == 0:
i = 0
j = (j + 1) % 8
print output