Created
November 4, 2012 11:59
-
-
Save lukasklein/4011593 to your computer and use it in GitHub Desktop.
One Time Pad Decryption
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
def decrypt(crypted, key): | |
plaintext = '' | |
chars = crypted.split(' ') | |
keys = key.split(' ') | |
if len(chars) != len(keys): | |
raise ValueError | |
plaintext = ''.join([chr(int(char, 16) ^ int(key, 16)) for char, key in zip(chars, keys)]) | |
return plaintext | |
if __name__ == "__main__": | |
print decrypt('1C 07 7F 6F A7 86 A6 E9 E5 75 78 A9 73 B9 17 2F D6 00 25 9F B4 86 16 07 4D 07 0F 98 0F AB 0F 6C 11 10 0F 34 21 FD 2D 69 B3 0D 7F 21 96 3C', '4F 4E 3A 4F F4 C5 EE A0 A0 26 2B EC 3D 99 53 66 93 20 67 CD FD C3 50 54 0E 4F 4E DE 5B EE 41 4C 55 45 5D 77 69 DD 68 20 FD 2D 2D 6E DE 6E') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment