self.iOSDeveloper self.iOSDeveloper - 1 year ago 333
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.

Answer Source

Python has native support for both HEX and base64 encoding:

encoded = HEX_STRING.decode("hex").encode("base64")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download