Last active
August 29, 2015 14:20
-
-
Save YarnSeemannsgarn/0d7d0d3e71bed6726371 to your computer and use it in GitHub Desktop.
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
# Hex xor by using strxor | |
def strxor(a, b): # xor two strings of different lengths | |
if len(a) > len(b): | |
return "".join([chr(ord(x) ^ ord(y)) for (x, y) in zip(a[:len(b)], b)]) | |
else: | |
return "".join([chr(ord(x) ^ ord(y)) for (x, y) in zip(a, b[:len(a)])]) | |
print "Hex 1: ", | |
a = raw_input().decode("hex") | |
print "Hex 2: ", | |
b = raw_input().decode("hex") | |
print strxor(a,b).encode("hex") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment