pybase64 is a Python library that provides a fast Base64 encoding/decoding implementation by wrapping the highly optimized `libbase64` C library. It maintains an active development status with regular updates to support new Python versions and performance enhancements. The current version is 1.4.3, and new releases often coincide with Python's release cycle.
pip install pybase64Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic Base64 encoding and decoding using `pybase64`. It shows both standard and URL-safe operations. For optimal decoding performance, especially with trusted input, using `validate=True` with `b64decode` is recommended.
Upgrade to Python 3.8 or newer, or pin pybase64 version to <1.4.0.
Call `pybase64.b64decode(encoded_bytes, validate=True)`
Upgrade to pybase64 version 1.3.2 or later.
Upgrade to pybase64 version 1.4.2 or later.
Convert `bytes` manually using `.decode('ascii')` or `.encode('ascii')`, or use `b64encode_as_string` / `b64decode_as_bytearray` for specific return types.Remove the `validate` argument when calling `pybase64.urlsafe_b64decode`.
Install the library using pip: `pip install pybase64`
Ensure the Base64 string is correctly padded (its length must be a multiple of 4, often by adding '=' characters at the end) and free of non-Base64 characters. You might need to add padding manually if it's missing: `s += '=' * (-len(s) % 4)` before decoding.
Do not attempt to decode the result of `pybase64.b64decode()` into a string unless you are certain of its original text encoding. If the original data was indeed a string with a specific encoding (e.g., 'latin-1' or 'cp1252'), use that encoding for decoding: `decoded_bytes.decode('latin-1')`. If the data is truly binary, keep it as `bytes`.To install the `pybase64` library, use the correct package name: `pip install pybase64`
No dependency data recorded yet.