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. The result is returned as a bytes object. A binascii.Error is raised if s
(s, casefold=False)
| 276 | |
| 277 | |
| 278 | def b16decode(s, casefold=False): |
| 279 | """Decode the Base16 encoded bytes-like object or ASCII string s. |
| 280 | |
| 281 | Optional casefold is a flag specifying whether a lowercase alphabet is |
| 282 | acceptable as input. For security purposes, the default is False. |
| 283 | |
| 284 | The result is returned as a bytes object. A binascii.Error is raised if |
| 285 | s is incorrectly padded or if there are non-alphabet characters present |
| 286 | in the input. |
| 287 | """ |
| 288 | s = _bytes_from_decode_data(s) |
| 289 | if casefold: |
| 290 | s = s.upper() |
| 291 | if re.search(b'[^0-9A-F]', s): |
| 292 | raise binascii.Error('Non-base16 digit found') |
| 293 | return binascii.unhexlify(s) |
| 294 | |
| 295 | # |
| 296 | # Ascii85 encoding/decoding |
nothing calls this directly
no test coverage detected