import base64 # this function takes a string representing hex, converts to bytes, and re-encodes to base64 def hex_to_base64(hex_string): byte_array = bytearray.fromhex(hex_string) base64_value = base64.b64encode(byte_array) return base64_value # this function takes two hex strings, converts them to bytes, and xor's them def byte_xor(bs1, bs2): byte_array1 = int(bs1,16) byte_array2 = int(bs2,16) return byte_array1 ^ byte_array2