Base64 is a representation of binary data based on 64 printable characters. Since 2^6=6, each bit is a unit that corresponds to a printable character.
3 bytes have 24 bits, corresponding to 4 Base64 units, 3 bytes can be represented by 4 printable characters. printable characters in Base64 include the letter A-Z, a-Z, number 0-9, a total of 62 characters, and two printable symbols in different systems. Base64 is often used to represent, transmit, and store binary data, including MIME e-mails and some complex XML data, in situations where text data is normally processed.
The Base64 module is available in the Python standard library for conversion
- Base64.b64encode () Base64 encode bytes type data, returning the encoded bytes type
- BASE64.B64DEOCDE () Decodes the Base64 encoded bytes type, returning the decoded bytes type
>>> Import base64>>> sb'\x80\x03}q\x00 (x\x01\x00\x00\x001q\x01}q \X02 (x\x05\x00\x00\x00countq\x03k\nx\x08\x00\x00\x00selectedq\x04\x88ux\x01\x00\x00\x002q\x05}q\x06 (h\x03K\ X14h\x04\x89uu. '>>> b = Base64.b64encode (s)>>> bb' gan9cqaowaeaaaaxcqf9cqiowauaaabjb3vudhedswpycaaaahnlbgvjdgvkcqsidvgbaaaamneffxegkggdsxrobil1ds4=' >>> Base64.b64decode (b) b'\x80\x03}q\x00 (x\x01\x00\x00\x001q\x01}q\x02 (x\x05 \x00\x00\x00countq\x03k\nx\x08\x00\x00\x00selectedq\x04
Use of the Base64 module and use in Python