Hex to Base64 conversion in Python

前端 未结 7 1045
一整个雨季
一整个雨季 2021-02-04 03:47

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,

7条回答
  •  旧巷少年郎
    2021-02-04 04:05

    In case someone is looking for a python3 one-liner (bash):

    python -c "import codecs as c; print(c.encode(c.decode('10000000000002ae', 'hex'), 'base64').decode())"
    

提交回复
热议问题