1515
1616This module provides functions for encoding binary data to printable
1717ASCII characters and decoding such encodings back to binary data.
18- It provides encoding and decoding functions for the encodings specified in
19- :rfc: `4648 `, which defines the Base16, Base32, and Base64 algorithms,
20- and for the de-facto standard Ascii85 and Base85 encodings.
21-
22- The :rfc: `4648 ` encodings are suitable for encoding binary data so that it can be
23- safely sent by email, used as parts of URLs, or included as part of an HTTP
24- POST request. The encoding algorithm is not the same as the
25- :program: `uuencode ` program.
18+ This includes the :ref: `encodings specified in <base64-rfc-4648 >`
19+ :rfc: `4648 ` (Base64, Base32 and Base16)
20+ and the non-standard :ref: `Base85 encodings <base64-base-85 >`.
2621
2722There are two interfaces provided by this module. The modern interface
2823supports encoding :term: `bytes-like objects <bytes-like object> ` to ASCII
2924:class: `bytes `, and decoding :term: `bytes-like objects <bytes-like object> ` or
3025strings containing ASCII to :class: `bytes `. Both base-64 alphabets
3126defined in :rfc: `4648 ` (normal, and URL- and filesystem-safe) are supported.
3227
33- The legacy interface does not support decoding from strings, but it does
28+ The :ref: ` legacy interface < base64-legacy >` does not support decoding from strings, but it does
3429provide functions for encoding and decoding to and from :term: `file objects
3530<file object> `. It only supports the Base64 standard alphabet, and it adds
3631newlines every 76 characters as per :rfc: `2045 `. Note that if you are looking
@@ -46,7 +41,15 @@ package instead.
4641 Any :term: `bytes-like objects <bytes-like object> ` are now accepted by all
4742 encoding and decoding functions in this module. Ascii85/Base85 support added.
4843
49- The modern interface provides:
44+
45+ .. _base64-rfc-4648 :
46+
47+ RFC 4648 Encodings
48+ ------------------
49+
50+ The :rfc: `4648 ` encodings are suitable for encoding binary data so that it can be
51+ safely sent by email, used as parts of URLs, or included as part of an HTTP
52+ POST request.
5053
5154.. function :: b64encode(s, altchars=None)
5255
@@ -181,6 +184,26 @@ The modern interface provides:
181184 incorrectly padded or if there are non-alphabet characters present in the
182185 input.
183186
187+ .. _base64-base-85 :
188+
189+ Base85 Encodings
190+ -----------------
191+
192+ Base85 encoding is not formally specified but rather a de facto standard,
193+ thus different systems perform the encoding differently.
194+
195+ The :func: `a85encode ` and :func: `b85encode ` functions in this module are two implementations of
196+ the de facto standard. You should call the function with the Base85
197+ implementation used by the software you intend to work with.
198+
199+ The two functions present in this module differ in how they handle the following:
200+
201+ * Whether to include enclosing ``<~ `` and ``~> `` markers
202+ * Whether to include newline characters
203+ * The set of ASCII characters used for encoding
204+ * Handling of null bytes
205+
206+ Refer to the documentation of the individual functions for more information.
184207
185208.. function :: a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False)
186209
@@ -262,7 +285,10 @@ The modern interface provides:
262285 .. versionadded :: 3.13
263286
264287
265- The legacy interface:
288+ .. _base64-legacy :
289+
290+ Legacy Interface
291+ ----------------
266292
267293.. function :: decode(input, output)
268294
0 commit comments