Skip to main content
https://img.shields.io/coveralls/inveniosoftware/base32-lib.svg https://img.shields.io/github/tag/inveniosoftware/base32-lib.svg https://img.shields.io/pypi/dm/base32-lib.svg https://img.shields.io/github/license/inveniosoftware/base32-lib.svg

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

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.1.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

base32_lib-1.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file base32_lib-1.1.1.tar.gz.

File metadata

  • Download URL: base32_lib-1.1.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for base32_lib-1.1.1.tar.gz
Algorithm Hash digest
SHA256 ab0b93c046f8ebb9af3a5295eadc68f447080257a331cd9b871f0418d9b5166b
MD5 317d8ac1f419e4326f8ccb23600332e9
BLAKE2b-256 0f814963fd2fa8626daf2860202bdc579b79c2e96f4f7636ae1c87e1e76f7cfe

See more details on using hashes here.

File details

Details for the file base32_lib-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: base32_lib-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for base32_lib-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef62b1fa9a20ddee2c0eac2eaf98540f2c6d0af5a806b43a716884ebeb07ac2a
MD5 8242ddc90601001198ca5fd00248f80e
BLAKE2b-256 fcc114bc1fdba1adccbecfdf2a99395f361e355107b03319583048441ef60d92

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page