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