def findXORLine(generator): lines = [challenge3.answer(l)[1] for l in generator] def compfunc(i): return challenge3.englishness(lines[i]) maxI = max(range(len(lines)), key=compfunc) return lines[maxI]
def FindKey(x, k): blocks = [x[i:i+k] for i in range(0, len(x), k)] transposed_blocks = list(itertools.zip_longest(*blocks, fillvalue = 0)) key = [challenge3.answer(bytes(x))[0] for x in transposed_blocks] return bytes(key)