base32-lib
Small library to generate, encode and decode random base32 strings with nice properties.
Usage
import base32_lib as base32
# Generate
## Generate a random identifier
base32.generate()
# -> 'abcd1234'
# Generate a random identifier with bells and whistle
base32.generate(length=10, split_every=5, checksum=True)
# -> '3sbk2-5j060'
# Encode a pre-existing number
base32.encode(1234, split_every=3, checksum=True) == "16j-82"
# Decode an identifier
base32.decode("16j-82", checksum=True) == 1234
base32.decode("16i-82", checksum=True)
# raises ValueError
Features
Generation, encoding and decoding of base32 strings
Douglas Crockford base32 encoding
URL-safe strings with no problematic special characters
Decoding of any-case strings
Configurable length strings
Randomness through cryptographically secure random number generator
Optional ISO-7064 checksum
Optional hyphenation
Supports uv
Installation
The base32-lib package is on PyPI so all you need is:
pip install base32-lib
Development
pipenv run pip install -e .[docs,tests]
Tests
pipenv run ./run-tests.sh
Metadata
Release files for base32-lib 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| base32_lib-1.1.1.tar.gz | 6.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| base32_lib-1.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.8 kB
Release files / base32_lib-1.1.1.tar.gz
| Download URL | base32_lib-1.1.1.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab0b93c046f8ebb9af3a5295eadc68f447080257a331cd9b871f0418d9b5166b
|
|
BLAKE2b-256 checksum How to use checksums |
0f814963fd2fa8626daf2860202bdc579b79c2e96f4f7636ae1c87e1e76f7cfe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Release files / base32_lib-1.1.1-py3-none-any.whl
| Download URL | base32_lib-1.1.1-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef62b1fa9a20ddee2c0eac2eaf98540f2c6d0af5a806b43a716884ebeb07ac2a
|
|
BLAKE2b-256 checksum How to use checksums |
fcc114bc1fdba1adccbecfdf2a99395f361e355107b03319583048441ef60d92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|