MCPcopy Index your code
hub / github.com/python/cpython / b16decode

Function b16decode

Lib/base64.py:281–302  ·  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. ignorechars should be a byte string containing characters to ignore from the inpu

(s, casefold=False, *, ignorechars=b'')

Source from the content-addressed store, hash-verified

279
280
281def 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

Callers

nothing calls this directly

Calls 2

_bytes_from_decode_dataFunction · 0.85
translateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…