Decode the Base16 encoded bytes-like object or ASCII string s. Optional casefold is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is False. ignorechars should be a byte string containing characters to ignore from the inpu
(s, casefold=False, *, ignorechars=b'')
| 279 | |
| 280 | |
| 281 | def b16decode(s, casefold=False, *, ignorechars=b''): |
| 282 | """Decode the Base16 encoded bytes-like object or ASCII string s. |
| 283 | |
| 284 | Optional casefold is a flag specifying whether a lowercase alphabet is |
| 285 | acceptable as input. For security purposes, the default is False. |
| 286 | |
| 287 | ignorechars should be a byte string containing characters to ignore |
| 288 | from the input. |
| 289 | |
| 290 | The result is returned as a bytes object. A binascii.Error is raised if |
| 291 | s is incorrectly padded or if there are non-alphabet characters present |
| 292 | in the input. |
| 293 | """ |
| 294 | if not casefold: |
| 295 | s = _bytes_from_decode_data(s) |
| 296 | if not isinstance(ignorechars, bytes): |
| 297 | ignorechars = bytes(memoryview(ignorechars)) |
| 298 | for b in b'abcdef': |
| 299 | if b in s and b not in ignorechars: |
| 300 | raise binascii.Error('Non-base16 digit found') |
| 301 | s = s.translate(None, delete=b'abcdef') |
| 302 | return binascii.unhexlify(s, ignorechars=ignorechars) |
| 303 | |
| 304 | # |
| 305 | # Ascii85 encoding/decoding |
nothing calls this directly
no test coverage detected
searching dependent graphs…