| 231 | b32encode.__doc__ = _B32_ENCODE_DOCSTRING.format(encoding='base32') |
| 232 | |
| 233 | def b32decode(s, casefold=False, map01=None, *, padded=True, ignorechars=b''): |
| 234 | s = _bytes_from_decode_data(s) |
| 235 | # Handle section 2.4 zero and one mapping. The flag map01 will be either |
| 236 | # False, or the character to map the digit 1 (one) to. It should be |
| 237 | # either L (el) or I (eye). |
| 238 | if map01 is not None: |
| 239 | map01 = _bytes_from_decode_data(map01) |
| 240 | s = s.translate(bytes.maketrans(b'01', b'O' + map01)) |
| 241 | if casefold: |
| 242 | s = s.upper() |
| 243 | return binascii.a2b_base32(s, padded=padded, ignorechars=ignorechars) |
| 244 | b32decode.__doc__ = _B32_DECODE_DOCSTRING.format(encoding='base32', |
| 245 | extra_args=_B32_DECODE_MAP01_DOCSTRING) |
| 246 | |