Skip to content

Commit 9ad2db8

Browse files
author
unicornsasfuel
committed
added min_keysize parameter to multi byte XOR cracker
1 parent 81ec1c2 commit 9ad2db8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

cryptanalib/modern.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ def break_single_byte_xor(ciphertext,num_answers=20,pt_freq_table=frequency.freq
10311031
# Return the best resulting plaintexts and associated score sorted by score
10321032
return sorted(answers.items(), key=lambda x: x[1])
10331033

1034-
def break_multi_byte_xor(ciphertext, max_keysize=40, num_answers=5, pt_freq_table=frequency.frequency_tables['english'], verbose=False):
1034+
def break_multi_byte_xor(ciphertext, max_keysize=40, num_answers=5, pt_freq_table=frequency.frequency_tables['english'], verbose=False, min_keysize=2):
10351035
'''
10361036
Return a list of likely successful multi-byte XOR decryptions sorted by score
10371037
@@ -1045,7 +1045,7 @@ def break_multi_byte_xor(ciphertext, max_keysize=40, num_answers=5, pt_freq_tabl
10451045
pt_freq_table_single_chars = dict(filter(lambda x: len(x[0])==1, pt_freq_table.items()))
10461046
edit_distances = {}
10471047
ciphertext_len = len(ciphertext)
1048-
for keysize in xrange(2,max_keysize+1):
1048+
for keysize in xrange(min_keysize,max_keysize+1):
10491049
ciphertext_chunks = split_into_blocks(ciphertext, keysize)
10501050
if len(ciphertext_chunks) < 3:
10511051
break

0 commit comments

Comments
 (0)