Skip to content

Instantly share code, notes, and snippets.

@mikeecb
Last active August 18, 2020 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeecb/ba92f9db295225da2b0c62de828b5fa8 to your computer and use it in GitHub Desktop.
Save mikeecb/ba92f9db295225da2b0c62de828b5fa8 to your computer and use it in GitHub Desktop.
Cryptopals Challenge Set 1 Exercise 5
def xor(b1, b2):
b = bytearray(len(b1))
for i in range(len(b1)):
b[i] = b1[i] ^ b2[i]
return b
lines = [
"Burning 'em, if you ain't quick and nimble\n",
"I go crazy when I hear a cymbal",
]
text = "".join(lines)
key = bytearray("ICE" * len(text))
plaintext = bytes(xor(bytearray(text), key))
plaintext.encode("hex")
# 0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c2a26226324272765272a282b2f20430a652e2c652a3124333a653e2b2027630c692b20283165286326302e27282f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment