blob: f196451f9390889954c323f798359235ed984162 [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}
Fred Drake79948431998-01-07 03:47:10 +00004\indexii{base-64}{encoding}
Fred Drake79948431998-01-07 03:47:10 +00005\index{MIME!base 64 encoding}
Guido van Rossume76b7a81997-04-27 21:25:52 +00006
7This module perform base-64 encoding and decoding of arbitrary binary
8strings into text strings that can be safely emailed or posted. The
Fred Drakec5891241998-02-09 19:16:20 +00009encoding scheme is defined in \rfc{1421} and is used for MIME email and
Guido van Rossume76b7a81997-04-27 21:25:52 +000010various other Internet-related applications; it is not the same as the
11output produced by the \file{uuencode} program. For example, the
12string \code{'www.python.org'} is encoded as the string
13\code{'d3d3LnB5dGhvbi5vcmc=\e n'}.
Guido van Rossume76b7a81997-04-27 21:25:52 +000014
Fred Drake19479911998-02-13 06:58:54 +000015\setindexsubitem{(in module base64)}
Fred Drake798654f1997-11-30 05:53:22 +000016
Fred Drake79948431998-01-07 03:47:10 +000017\begin{funcdesc}{decode}{input, output}
Guido van Rossume76b7a81997-04-27 21:25:52 +000018Decode the contents of the \var{input} file and write the resulting
19binary data to the \var{output} file.
20\var{input} and \var{output} must either be file objects or objects that
21mimic the file object interface. \var{input} will be read until
22\code{\var{input}.read()} returns an empty string.
23\end{funcdesc}
24
25\begin{funcdesc}{decodestring}{s}
26Decode the string \var{s}, which must contain one or more lines of
27base-64 encoded data, and return a string containing the resulting
28binary data.
29\end{funcdesc}
30
Fred Drake79948431998-01-07 03:47:10 +000031\begin{funcdesc}{encode}{input, output}
Guido van Rossume76b7a81997-04-27 21:25:52 +000032Encode the contents of the \var{input} file and write the resulting
33base-64 encoded data to the \var{output} file.
34\var{input} and \var{output} must either be file objects or objects that
35mimic the file object interface. \var{input} will be read until
36\code{\var{input}.read()} returns an empty string.
37\end{funcdesc}
38
39\begin{funcdesc}{encodestring}{s}
40Encode the string \var{s}, which can contain arbitrary binary data,
41and return a string containing one or more lines of
42base-64 encoded data.
43\end{funcdesc}
44
45