pybase62 is a Python module providing base62 encoding and decoding functionalities. It allows for creating short, URL-safe identifiers, as it avoids special characters like '/' or '=' found in base64. A key advantage is that the alphabetical order of the original data is preserved when encoded, meaning encoded data can be sorted without prior decoding. The current stable version is 1.0.0, released in May 2023, with development tracked on GitHub.
pip install pybase62Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic integer and byte array encoding and decoding using the `base62` module. It highlights the primary `encode`/`decode` functions for integers and `encodebytes`/`decodebytes` for byte arrays.
Always use `import base62` or `from base62 import ...` after installing `pybase62`.
Ensure `bytes` are passed to `encodebytes()` and `str` to `decodebytes()`. They are designed to be commutative: `value_str == encodebytes(decodebytes(value_str))` and `value_bytes == decodebytes(encodebytes(value_bytes))`.
Stick to a single `base62` library throughout your project to ensure consistent encoding and decoding. If interoperability is required, verify the exact character set and algorithm used by each implementation.
Install the package using `pip install pybase62` and then import it in your code using `import base62`.
Use the `base62.encodebytes()` function for encoding `bytes` objects, or convert your bytes object to an integer before passing it to `base62.encode()`.
Ensure the input to `base62.decodebytes()` is a `str` type. If you have a `bytes` object that needs to be decoded, first convert it to a string (e.g., `my_bytes.decode('ascii')`).Upgrade the `pybase62` package to the latest version using `pip install --upgrade pybase62`.
No dependency data recorded yet.