self.iOSDeveloper self.iOSDeveloper - 25 days ago 4
Python Question

Hex to Base64 convertion

I want to convert a simple HEX string such as 10000000000002ae to Base 64.

The hex string is to be converted to bytes, and the bytes are then encoded to base64 notation, so the expected output for that string: EAAAAAAAAq4=

I found a tool online.

But I have a bunch of HEX values that I need to convert in a script.


Python has native support for both HEX and base64 encoding:

encoded = HEX_STRING.decode("hex").encode("base64")