Git Product home page Git Product logo

base32-lib's Introduction

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

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

base32-lib's People

Contributors

fenekku avatar lnielsen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.