Small library to generate, encode and decode random base32 strings.
Project description
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
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
Changes
Version 1.0.0 (2019-10-XX)
First public release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
base32-lib-1.0.1.tar.gz
(12.9 kB
view hashes)
Built Distribution
Close
Hashes for base32_lib-1.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebbf80687ef9791580135f372db1c0a09a1a5d02089d57a8a49bf5ef3330221f |
|
MD5 | 82752a634c6423912a0f8ffa6d45c6a1 |
|
BLAKE2b-256 | f34b402af6262120ee1e30bbf5a222e193da1aeabb36583f53cecd59777a8aee |