rest25/library/base64.rst => rest262/library/base64.rst
16email, used as parts of URLs, or included as part of an HTTP POST request.  The
17encoding algorithm is not the same as the :program:`uuencode` program.
18
19There are two interfaces provided by this module.  The modern interface supports
20encoding and decoding string objects using all three alphabets.  The legacy
21interface provides for encoding and decoding to and from file-like objects as
22well as strings, but only using the Base64 standard alphabet.
23
n24-The modern interface provides:
n24+The modern interface, which was introduced in Python 2.4, provides:
25
26
27.. function:: b64encode(s[, altchars])
28
29   Encode a string use Base64.
30
31   *s* is the string to encode.  Optional *altchars* must be a string of at least
32   length 2 (additional characters are ignored) which specifies an alternative
58.. function:: standard_b64decode(s)
59
60   Decode string *s* using the standard Base64 alphabet.
61
62
63.. function:: urlsafe_b64encode(s)
64
65   Encode string *s* using a URL-safe alphabet, which substitutes ``-`` instead of
n66-   ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet.
n66+   ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet.  The result
67+   can still contain ``=``.
67
68
69.. function:: urlsafe_b64decode(s)
70
71   Decode string *s* using a URL-safe alphabet, which substitutes ``-`` instead of
72   ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet.
73
74
84
85   *s* is the string to decode.  Optional *casefold* is a flag specifying whether a
86   lowercase alphabet is acceptable as input.  For security purposes, the default
87   is ``False``.
88
89   :rfc:`3548` allows for optional mapping of the digit 0 (zero) to the letter O
90   (oh), and for optional mapping of the digit 1 (one) to either the letter I (eye)
91   or letter L (el).  The optional argument *map01* when not ``None``, specifies
n92-   which letter the digit 1 should be mapped to (when map01 is not *None*, the
n93+   which letter the digit 1 should be mapped to (when *map01* is not ``None``, the
93   digit 0 is always mapped to the letter O).  For security purposes the default is
94   ``None``, so that 0 and 1 are not allowed in the input.
95
96   The decoded string is returned.  A :exc:`TypeError` is raised if *s* were
97   incorrectly padded or if there are non-alphabet characters present in the
98   string.
99
100
145
146.. function:: encodestring(s)
147
148   Encode the string *s*, which can contain arbitrary binary data, and return a
149   string containing one or more lines of base64-encoded data.
150   :func:`encodestring` returns a string containing one or more lines of
151   base64-encoded data always including an extra trailing newline (``'\n'``).
152
t153-An example usage of the module::
t154+An example usage of the module:
154
155   >>> import base64
156   >>> encoded = base64.b64encode('data to be encoded')
157   >>> encoded
158   'ZGF0YSB0byBiZSBlbmNvZGVk'
159   >>> data = base64.b64decode(encoded)
160   >>> data
161   'data to be encoded'
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op