What is the fastest way to implementat the following logic:
def xor(data, key):
l = len(key)
buff = \"\"
for i in range(0, len(data)):
b
Following on my comment in the initial post, you can process large files rather quickly if you stick to numpy for key padding and bitwise XOR'ing, like so:
import numpy as np
# ...
def xor(key, data):
data = np.fromstring(data, dtype=np.byte)
key = np.fromstring(key, dtype=np.byte)
# Pad the key to match the data length
key = np.pad(key, (0, len(data) - len(key)), 'wrap')
return np.bitwise_xor(key, data)