1 \section{\module{base64
} ---
2 Encode and decode MIME base64 data
}
4 \declaremodule{standard
}{base64
}
5 \modulesynopsis{Encode and decode files using the MIME base64 data.
}
8 \indexii{base64
}{encoding
}
9 \index{MIME!base64 encoding
}
11 This module performs base64 encoding and decoding of arbitrary binary
12 strings into text strings that can be safely emailed or posted. The
13 encoding scheme is defined in
\rfc{1521} (
\emph{MIME
14 (Multipurpose Internet Mail Extensions) Part One: Mechanisms for
15 Specifying and Describing the Format of Internet Message Bodies
},
16 section
5.2, ``Base64 Content-Transfer-Encoding'') and is used for
17 MIME email and various other Internet-related applications; it is not
18 the same as the output produced by the
\program{uuencode
} program.
19 For example, the string
\code{'www.python.org'
} is encoded as the
20 string
\code{'d3d3LnB5dGhvbi5vcmc=
\e n'
}.
23 \begin{funcdesc
}{decode
}{input, output
}
24 Decode the contents of the
\var{input
} file and write the resulting
25 binary data to the
\var{output
} file.
26 \var{input
} and
\var{output
} must either be file objects or objects that
27 mimic the file object interface.
\var{input
} will be read until
28 \code{\var{input
}.read()
} returns an empty string.
31 \begin{funcdesc
}{decodestring
}{s
}
32 Decode the string
\var{s
}, which must contain one or more lines of
33 base64 encoded data, and return a string containing the resulting
37 \begin{funcdesc
}{encode
}{input, output
}
38 Encode the contents of the
\var{input
} file and write the resulting
39 base64 encoded data to the
\var{output
} file.
40 \var{input
} and
\var{output
} must either be file objects or objects that
41 mimic the file object interface.
\var{input
} will be read until
42 \code{\var{input
}.read()
} returns an empty string.
45 \begin{funcdesc
}{encodestring
}{s
}
46 Encode the string
\var{s
}, which can contain arbitrary binary data,
47 and return a string containing one or more lines of
53 \seemodule{binascii
}{support module containing
\ASCII{}-to-binary
54 and binary-to-
\ASCII{} conversions
}
55 \seetext{Internet
\rfc{1521},
\emph{MIME (Multipurpose Internet
56 Mail Extensions) Part One: Mechanisms for Specifying and
57 Describing the Format of Internet Message Bodies
}, section
58 5.2, ``Base64 Content-Transfer-Encoding,'' provides the
59 definition of the base64 encoding.
}