February 2006
Intermediate to advanced
648 pages
14h 53m
English
The base64 module is used to encode and decode data using base 64, base 32, or base 16 encoding. Base 64 is commonly used to embed binary data in mail attachments.
Base 64 encoding works by grouping the data to be encoded into groups of 24 bits (3 bytes). Each 24-bit group is then subdivided into four 6-bit components. Each 6-bit value is then represented by a printable ASCII character from the following alphabet:
| Value | Encoding |
|---|---|
| 0–25 | ABCDEFGHIJKLMNOPQRSTUVWXYZ |
| 26–51 | abcdefghijklmnopqrstuvwxyz |
| 52–61 | 0123456789 |
| 62 | + |
| 63 | / |
| pad | = |
If the number of bytes in the input stream is not a multiple of 3 (24 bits), the data is padded to form a complete 24-bit group. The extra padding is then indicated by special ‘=’ characters that appear at the end of the encoding. ...