@@ -48,12 +48,15 @@ The :mod:`!binascii` module defines the following functions:
4848 Added the *backtick * parameter.
4949
5050
51- .. function :: a2b_base64(string, /, *, strict_mode=False)
52- a2b_base64(string, /, *, strict_mode=True, ignorechars )
51+ .. function :: a2b_base64(string, /, *, alphabet=BASE64_ALPHABET, strict_mode=False)
52+ a2b_base64(string, /, *, ignorechars, alphabet=BASE64_ALPHABET, strict_mode=True )
5353
5454 Convert a block of base64 data back to binary and return the binary data. More
5555 than one line may be passed at a time.
5656
57+ Optional *alphabet * must be a :class: `bytes ` object of length 64 which
58+ specifies an alternative alphabet.
59+
5760 If *ignorechars * is specified, it should be a :term: `bytes-like object `
5861 containing characters to ignore from the input when *strict_mode * is true.
5962 If *ignorechars * contains the pad character ``'=' ``, the pad characters
@@ -76,10 +79,10 @@ The :mod:`!binascii` module defines the following functions:
7679 Added the *strict_mode * parameter.
7780
7881 .. versionchanged :: 3.15
79- Added the *ignorechars * parameter .
82+ Added the *alphabet * and * ignorechars * parameters .
8083
8184
82- .. function :: b2a_base64(data, *, wrapcol=0, newline=True)
85+ .. function :: b2a_base64(data, *, alphabet=BASE64_ALPHABET, wrapcol=0, newline=True)
8386
8487 Convert binary data to a line(s) of ASCII characters in base64 coding,
8588 as specified in :rfc: `4648 `.
@@ -95,7 +98,7 @@ The :mod:`!binascii` module defines the following functions:
9598 Added the *newline * parameter.
9699
97100 .. versionchanged :: 3.15
98- Added the *wrapcol * parameter .
101+ Added the *alphabet * and * wrapcol * parameters .
99102
100103
101104.. function :: a2b_ascii85(string, /, *, foldspaces=False, adobe=False, ignorechars=b"")
@@ -148,7 +151,7 @@ The :mod:`!binascii` module defines the following functions:
148151 .. versionadded :: 3.15
149152
150153
151- .. function :: a2b_base85(string, /)
154+ .. function :: a2b_base85(string, /, *, alphabet=BASE85_ALPHABET )
152155
153156 Convert Base85 data back to binary and return the binary data.
154157 More than one line may be passed at a time.
@@ -158,49 +161,25 @@ The :mod:`!binascii` module defines the following functions:
158161 characters). Each group encodes 32 bits of binary data in the range from
159162 ``0 `` to ``2 ** 32 - 1 ``, inclusive.
160163
164+ Optional *alphabet * must be a :class: `bytes ` object of length 85 which
165+ specifies an alternative alphabet.
166+
161167 Invalid Base85 data will raise :exc: `binascii.Error `.
162168
163169 .. versionadded :: 3.15
164170
165171
166- .. function :: b2a_base85(data, /, *, pad=False)
172+ .. function :: b2a_base85(data, /, *, alphabet=BASE85_ALPHABET, pad=False)
167173
168174 Convert binary data to a line of ASCII characters in Base85 coding.
169175 The return value is the converted line.
170176
171- If *pad * is true, the input is padded with ``b'\0' `` so its length is a
172- multiple of 4 bytes before encoding.
173-
174- .. versionadded :: 3.15
175-
176-
177- .. function :: a2b_z85(string, /)
178-
179- Convert Z85 data back to binary and return the binary data.
180- More than one line may be passed at a time.
181-
182- Valid Z85 data contains characters from the Z85 alphabet in groups
183- of five (except for the final group, which may have from two to five
184- characters). Each group encodes 32 bits of binary data in the range from
185- ``0 `` to ``2 ** 32 - 1 ``, inclusive.
186-
187- See `Z85 specification <https://rfc.zeromq.org/spec/32/ >`_ for more information.
188-
189- Invalid Z85 data will raise :exc: `binascii.Error `.
190-
191- .. versionadded :: 3.15
192-
193-
194- .. function :: b2a_z85(data, /, *, pad=False)
195-
196- Convert binary data to a line of ASCII characters in Z85 coding.
197- The return value is the converted line.
177+ Optional *alphabet * must be a :term: `bytes-like object ` of length 85 which
178+ specifies an alternative alphabet.
198179
199180 If *pad * is true, the input is padded with ``b'\0' `` so its length is a
200181 multiple of 4 bytes before encoding.
201182
202- See `Z85 specification <https://rfc.zeromq.org/spec/32/ >`_ for more information.
203-
204183 .. versionadded :: 3.15
205184
206185
@@ -300,6 +279,55 @@ The :mod:`!binascii` module defines the following functions:
300279 but may be handled by reading a little more data and trying again.
301280
302281
282+ .. data :: BASE64_ALPHABET
283+
284+ The Base 64 alphabet according to :rfc: `4648 `.
285+
286+ .. versionadded :: next
287+
288+ .. data :: URLSAFE_BASE64_ALPHABET
289+
290+ The "URL and filename safe" Base 64 alphabet according to :rfc: `4648 `.
291+
292+ .. versionadded :: next
293+
294+ .. data :: UU_ALPHABET
295+
296+ The uuencoding alphabet.
297+
298+ .. versionadded :: next
299+
300+ .. data :: CRYPT_ALPHABET
301+
302+ The Base 64 alphabet used in the :manpage: `crypt(3)` routine and in the GEDCOM format.
303+
304+ .. versionadded :: next
305+
306+ .. data :: BINHEX_ALPHABET
307+
308+ The Base 64 alphabet used in BinHex 4 (HQX) within the classic Mac OS.
309+
310+ .. versionadded :: next
311+
312+ .. data :: BASE85_ALPHABET
313+
314+ The Base85 alphabet.
315+
316+ .. versionadded :: next
317+
318+ .. data :: ASCII85_ALPHABET
319+
320+ The Ascii85 alphabet.
321+
322+ .. versionadded :: next
323+
324+ .. data :: Z85_ALPHABET
325+
326+ The `Z85 <https://rfc.zeromq.org/spec/32/ >`_ alphabet.
327+
328+ .. versionadded :: next
329+
330+
303331.. seealso ::
304332
305333 Module :mod: `base64 `
0 commit comments