15
15
16
16
This module provides functions for encoding binary data to printable
17
17
ASCII 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 >`.
26
21
27
22
There are two interfaces provided by this module. The modern interface
28
23
supports encoding:term: `bytes-like objects <bytes-like object> ` to ASCII
29
24
:class: `bytes `, and decoding:term: `bytes-like objects <bytes-like object> ` or
30
25
strings containing ASCII to:class: `bytes `. Both base-64 alphabets
31
26
defined in:rfc: `4648 ` (normal, and URL- and filesystem-safe) are supported.
32
27
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
34
29
provide functions for encoding and decoding to and from:term: `file objects
35
30
<file object> `. It only supports the Base64 standard alphabet, and it adds
36
31
newlines every 76 characters as per:rfc: `2045 `. Note that if you are looking
@@ -46,7 +41,15 @@ package instead.
46
41
Any:term: `bytes-like objects <bytes-like object> ` are now accepted by all
47
42
encoding and decoding functions in this module. Ascii85/Base85 support added.
48
43
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.
50
53
51
54
..function ::b64encode(s, altchars=None)
52
55
@@ -181,6 +184,26 @@ The modern interface provides:
181
184
incorrectly padded or if there are non-alphabet characters present in the
182
185
input.
183
186
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.
184
207
185
208
..function ::a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False)
186
209
@@ -262,7 +285,10 @@ The modern interface provides:
262
285
..versionadded ::3.13
263
286
264
287
265
- The legacy interface:
288
+ .. _base64-legacy :
289
+
290
+ Legacy Interface
291
+ ----------------
266
292
267
293
..function ::decode(input, output)
268
294