MCPcopy Index your code
hub / github.com/RustPython/RustPython / b16decode

Function b16decode

Lib/base64.py:273–288  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

271
272
273def 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

Callers

nothing calls this directly

Calls 3

_bytes_from_decode_dataFunction · 0.85
upperMethod · 0.45
translateMethod · 0.45

Tested by

no test coverage detected