PyDocs

Nav

Internet Data Handling

b64decode

base64

function (source) Deprecated 3.15
  • b64decode(s, altchars=None, validate=False, *, padded=True, canonical=False)
  • b64decode(s, altchars=None, validate=True, *, ignorechars, padded=True, canonical=False)
Deprecated since 3.15. Accepting the + and / characters with an alternative alphabet is now deprecated.
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.

If padded is false, padding in input is not required.

The result is returned as a bytes object.  A binascii.Error is raised if
s is incorrectly padded.

If ignorechars is specified, it should be a byte string containing
characters to ignore from the input.  The default value of validate is
True if ignorechars is specified, False otherwise.

If validate is false, characters that are neither in the normal base-64
alphabet nor the alternative alphabet are discarded prior to the
padding check.  If validate is true, these non-alphabet characters in
the input result in a binascii.Error if they are not in ignorechars.
For more information about the strict base64 check, see:

https://docs.python.org/3.11/library/binascii.html#binascii.a2b_base64
Changed in 3.15
  • 3.15: Added the canonical, ignorechars, and padded parameters.
1 Example
>>> import base64
>>> encoded = base64.b64encode(b'data to be encoded')
>>> encoded
b'ZGF0YSB0byBiZSBlbmNvZGVk'
>>> data = base64.b64decode(encoded)
>>> data
b'data to be encoded'
from the Python docs
See Also
No see-alsos for base64/b64decode
0 Notes
No notes for b64decode