Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 1 | \section{Standard Module \sectcode{base64}} |
| 2 | \stmodindex{base64} |
| 3 | |
| 4 | This module perform base-64 encoding and decoding of arbitrary binary |
| 5 | strings into text strings that can be safely emailed or posted. The |
| 6 | encoding scheme is defined in RFC 1421 and is used for MIME email and |
| 7 | various other Internet-related applications; it is not the same as the |
| 8 | output produced by the \file{uuencode} program. For example, the |
| 9 | string \code{'www.python.org'} is encoded as the string |
| 10 | \code{'d3d3LnB5dGhvbi5vcmc=\e n'}. |
| 11 | \indexii{base-64}{encoding} |
| 12 | \indexii{RFC}{1421} |
| 13 | \index{MIME, base 64 encoding} |
| 14 | |
| 15 | \begin{funcdesc}{decode}{input\, output} |
| 16 | Decode the contents of the \var{input} file and write the resulting |
| 17 | binary data to the \var{output} file. |
| 18 | \var{input} and \var{output} must either be file objects or objects that |
| 19 | mimic the file object interface. \var{input} will be read until |
| 20 | \code{\var{input}.read()} returns an empty string. |
| 21 | \end{funcdesc} |
| 22 | |
| 23 | \begin{funcdesc}{decodestring}{s} |
| 24 | Decode the string \var{s}, which must contain one or more lines of |
| 25 | base-64 encoded data, and return a string containing the resulting |
| 26 | binary data. |
| 27 | \end{funcdesc} |
| 28 | |
| 29 | \begin{funcdesc}{encode}{input\, output} |
| 30 | Encode the contents of the \var{input} file and write the resulting |
| 31 | base-64 encoded data to the \var{output} file. |
| 32 | \var{input} and \var{output} must either be file objects or objects that |
| 33 | mimic the file object interface. \var{input} will be read until |
| 34 | \code{\var{input}.read()} returns an empty string. |
| 35 | \end{funcdesc} |
| 36 | |
| 37 | \begin{funcdesc}{encodestring}{s} |
| 38 | Encode the string \var{s}, which can contain arbitrary binary data, |
| 39 | and return a string containing one or more lines of |
| 40 | base-64 encoded data. |
| 41 | \end{funcdesc} |
| 42 | |
| 43 | |