+ return codecs.encode(bytes.fromhex(_hex), 'base64').decode('utf-8')
+
+def hex_xor(hex0, hex1):
+ assert len(hex0) == len(hex1)
+ bytes0 = bytes.fromhex(hex0)
+ bytes1 = bytes.fromhex(hex1)
+ xored_bytes = bytes(byte0 ^ byte1 for byte0, byte1 in zip(bytes0, bytes1))
+ return codecs.encode(xored_bytes, 'hex').decode('utf-8')