Skip to main content

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.


import base32_lib as base32

# Generate
## Generate a random identifier
# -> '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


  • 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


The base32-lib package is on PyPI so all you need is:

pip install base32-lib


pipenv run pip install -e .[docs,tests]


pipenv run ./


Version 1.0.2 (2020-05-07)

  • Deprecate Python versions lower than 3.6.0. Now supporting 3.6.0 and 3.7.0.

Version 1.0.1 (2019-11-15)

  • Enforce appropriate length of the encoded base32 strings.

Version 1.0.0 (2019-11-06)

  • First public release.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for base32-lib, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size base32_lib-1.0.2-py2.py3-none-any.whl (6.7 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size base32-lib-1.0.2.tar.gz (13.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page