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

Function b64decode

Lib/base64.py:62–85  ·  view source on GitHub ↗

Decode the Base64 encoded bytes-like object or ASCII string s. Optional altchars must be a bytes-like object or ASCII string of length 2 which specifies the alternative alphabet used instead of the '+' and '/' characters. The result is returned as a bytes object. A binascii.Error

(s, altchars=None, validate=False)

Source from the content-addressed store, hash-verified

60
61
62def b64decode(s, altchars=None, validate=False):
63 """Decode the Base64 encoded bytes-like object or ASCII string s.
64
65 Optional altchars must be a bytes-like object or ASCII string of length 2
66 which specifies the alternative alphabet used instead of the '+' and '/'
67 characters.
68
69 The result is returned as a bytes object. A binascii.Error is raised if
70 s is incorrectly padded.
71
72 If validate is False (the default), characters that are neither in the
73 normal base-64 alphabet nor the alternative alphabet are discarded prior
74 to the padding check. If validate is True, these non-alphabet characters
75 in the input result in a binascii.Error.
76 For more information about the strict base64 check, see:
77
78 https://docs.python.org/3.11/library/binascii.html#binascii.a2b_base64
79 """
80 s = _bytes_from_decode_data(s)
81 if altchars is not None:
82 altchars = _bytes_from_decode_data(altchars)
83 assert len(altchars) == 2, repr(altchars)
84 s = s.translate(bytes.maketrans(altchars, b'+/'))
85 return binascii.a2b_base64(s, strict_mode=validate)
86
87
88def standard_b64encode(s):

Callers 2

standard_b64decodeFunction · 0.85
urlsafe_b64decodeFunction · 0.85

Calls 5

_bytes_from_decode_dataFunction · 0.85
lenFunction · 0.85
reprFunction · 0.85
translateMethod · 0.45
maketransMethod · 0.45

Tested by

no test coverage detected