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