how can we XOR hex numbers in python eg. I want to xor \'ABCD\' to \'12EF\'. answer should be B922.
i used below code but it is returning garbage value
here's a better function
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)])])