Created
April 20, 2017 12:50
-
-
Save mikeecb/9ea6fe5252252603373c8a2f1ac921c0 to your computer and use it in GitHub Desktop.
Cryptopals Challenge Set 1 Exercise 4 Simplified
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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