base32-crockford is a Python library that implements Douglas Crockford's base32 encoding scheme. This scheme is designed for human and machine readability, compactness, error resistance, and pronounceability. The library is currently at version 0.3.0, released in 2015, suggesting a maintenance-only release cadence.
pip install base32-crockfordVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to encode and decode integers, use the optional checksum feature, and normalize base32 strings according to Crockford's rules.
If strict input validation is required, use `strict=True` in `decode()` or `normalize()`, but be prepared for `ValueError` if normalization would be needed. Alternatively, pre-normalize with `normalize()` and inspect the result before decoding.
Always use `checksum=True` when decoding strings that were originally encoded with a checksum to ensure data integrity.
Convert `bytes` objects to integers before encoding (e.g., using `int.from_bytes(my_bytes, 'big')`) and convert the decoded integer back to bytes (e.g., using `my_integer.to_bytes(length, 'big')`) after decoding.
Consider potential long-term maintenance or compatibility risks. For new projects, evaluate more actively maintained alternatives if the core functionality of Crockford's base32 is not strictly required, or if `bytes` encoding/decoding is needed out-of-the-box.
Ensure that the input string is complete and uncorrupted. If the original string was not encoded with a checksum, remove `checksum=True` from the `decode()` call. If it was, verify the integrity of the string being decoded.
To allow the library to perform automatic normalization, remove the `strict=True` argument. If strict validation is desired, pre-process the input string to conform to uppercase, hyphen-free, and unambiguous character rules before calling `decode(strict=True)`.
Convert the input data to an integer before calling `encode()`. For example, to encode bytes, use `int.from_bytes(my_bytes_object, 'big')`.
No dependency data recorded yet.