Base64 1
Base64 — Data encoding
Base64 is a widely used method of encoding data that makes it possible to represent binary data using the ASCII character set. This method uses a special alphabet consisting of only 64 characters.
Each Base64 character represents 6 bits of data. Therefore, 4 Base64 characters encode 3 8-bit bytes (that is, 24 bits). This format is often used on the internet because it makes it easy to embed binary data from images or files into text files such as HTML or CSS.
Below is data written in hexadecimal (hex format). First decode it into bytes, then re-encode it into Base64 format.
Given hex string:
7e56a0fc16ac7beeb8fa4a1d95ab21fa29ed7ab9deb5d6be8ac8656ad8a569d8bf
To do this in Python, first convert the hex string into bytes
(using the bytes.fromhex() function).
Then, via import base64,
the base64 module is imported, and
using the base64.b64encode() function,
the data is encoded into Base64 format.