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

Function b64encode

Lib/base64.py:48–59  ·  view source on GitHub ↗

Encode the bytes-like object s using Base64 and return a bytes object. Optional altchars should be a byte string of length 2 which specifies an alternative alphabet for the '+' and '/' characters. This allows an application to e.g. generate url or filesystem safe Base64 strings.

(s, altchars=None)

Source from the content-addressed store, hash-verified

46# Base64 encoding/decoding uses binascii
47
48def b64encode(s, altchars=None):
49 """Encode the bytes-like object s using Base64 and return a bytes object.
50
51 Optional altchars should be a byte string of length 2 which specifies an
52 alternative alphabet for the '+' and '/' characters. This allows an
53 application to e.g. generate url or filesystem safe Base64 strings.
54 """
55 encoded = binascii.b2a_base64(s, newline=False)
56 if altchars is not None:
57 assert len(altchars) == 2, repr(altchars)
58 return encoded.translate(bytes.maketrans(b'+/', altchars))
59 return encoded
60
61
62def b64decode(s, altchars=None, validate=False):

Callers 4

header_encodeFunction · 0.90
standard_b64encodeFunction · 0.85
urlsafe_b64encodeFunction · 0.85

Calls 4

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

Tested by 1