Use of the Base64 module and use in Python

Source: Internet
Author: User
Tags base64 base64 encode printable characters

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.