Skip to main content

Small library to generate, encode and decode random base32 strings.

Project description

https://img.shields.io/travis/inveniosoftware/base32-lib.svg 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 strings

  • Decoding of any-case strings

  • Configurable length strings

  • Randomness through cryptographically secure random number generator

  • Douglas Crockford base32 encoding

  • URL-safe strings with no problematic special characters

  • 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


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.0a1.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

base32_lib-1.0.0a1-py2.py3-none-any.whl (6.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file base32-lib-1.0.0a1.tar.gz.

File metadata

  • Download URL: base32-lib-1.0.0a1.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.6.7

File hashes

Hashes for base32-lib-1.0.0a1.tar.gz
Algorithm Hash digest
SHA256 a07c0e74b890547cc6590abc6a83620dbf4fcd5694711eea64706e9f23344b8f
MD5 1d05b5df8faf0b1473e11991e7817dfe
BLAKE2b-256 d0912a04da054ec9a83ff77af6aeb32cad0529407ff7d3a1d0dd7cc282babc35

See more details on using hashes here.

File details

Details for the file base32_lib-1.0.0a1-py2.py3-none-any.whl.

File metadata

  • Download URL: base32_lib-1.0.0a1-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.6.7

File hashes

Hashes for base32_lib-1.0.0a1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 77f99f56f9d2b679f69b23fcfac1713f233eb2540f4d772871591020de46225a
MD5 70413a441806dd8fefa1a81ce1436ae8
BLAKE2b-256 c29a4f0f47fb40ad435f71cfd7f122149b00836b664188fd89da363d6601c219

See more details on using hashes here.

Supported by

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