pybase64
is a wrapper on libbase64.
It aims to provide a fast base64 implementation for base64 encoding/decoding.
pip install pybase64
pybase64
uses the same API as Python base64
"modern interface" (introduced in Python 2.4) for an easy integration.
To get the fastest decoding, it is recommended to use the ~pybase64.b64decode
and validate=True when possible.
import pybase64
print(pybase64.b64encode(b'>>>foo???', altchars='_:'))
# b'Pj4_Zm9vPz8:'
print(pybase64.b64decode(b'Pj4_Zm9vPz8:', altchars='_:', validate=True))
# b'>>>foo???'
# Standard encoding helpers
print(pybase64.standard_b64encode(b'>>>foo???'))
# b'Pj4+Zm9vPz8/'
print(pybase64.standard_b64decode(b'Pj4+Zm9vPz8/'))
# b'>>>foo???'
# URL safe encoding helpers
print(pybase64.urlsafe_b64encode(b'>>>foo???'))
# b'Pj4-Zm9vPz8_'
print(pybase64.urlsafe_b64decode(b'Pj4-Zm9vPz8_'))
# b'>>>foo???'
Check api
for more details.