def probable_key_lengths(ciphertext):
keysizes = []
for ksize in range(2, 41):
hammingtotals = []
hammings = 0
chunklist = list(chunks(ciphertext, ksize))
for c1 in chunklist:
for c2 in chunklist:
if c1 is c2:
continue
hammingtotals.append(hamming(c1, c2) / ksize)
keysizes.append((sum(hammingtotals) / len(hammingtotals), ksize))
keysizes.sort()
return keysizes