Created
March 12, 2012 09:40
-
-
Save stephenpaulger/2020941 to your computer and use it in GitHub Desktop.
Why two time pads are a BadThing™
This file contains hidden or 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
#!/usr/bin/env python | |
def xor_int_tuple(tup): | |
return reduce(lambda a,b:a^b, tup) | |
def xor_tuple(tup): | |
return ord(tup[0]) ^ ord(tup[1]) | |
def encrypt(m, k, op=xor_tuple): | |
return map(op, zip(m, k)) | |
k = "abcdefg" | |
c1 = encrypt("Stephen", k) | |
c2 = encrypt("Joanna", k) | |
print c1 | |
print c2 | |
print encrypt(c1, c2, op=xor_int_tuple) | |
print encrypt("Stephen", "Joanna") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[50, 22, 6, 20, 13, 3, 9]
[43, 13, 2, 10, 11, 7]
[25, 27, 4, 30, 6, 4]
[25, 27, 4, 30, 6, 4]