Skip to content

Instantly share code, notes, and snippets.

@mikeecb
Created April 20, 2017 12:50
Show Gist options
  • Save mikeecb/9ea6fe5252252603373c8a2f1ac921c0 to your computer and use it in GitHub Desktop.
Save mikeecb/9ea6fe5252252603373c8a2f1ac921c0 to your computer and use it in GitHub Desktop.
Cryptopals Challenge Set 1 Exercise 4 Simplified
max_score = None
english_plaintext = None
key = None
for line in open("4.txt", "r"):
line = line.rstrip()
b1 = bytearray.fromhex(line)
for i in range(256):
b2 = [i] * len(b1)
plaintext = bytes(xor(b1, b2))
pscore = score(plaintext)
if pscore > max_score or not max_score:
max_score = pscore
english_plaintext = plaintext
key = chr(i)
print key, english_plaintext
# 5 Now that the party is jumping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment