Metadata-Version: 2.4
Name: base32-lib
Version: 1.1.1
Summary: Small library to generate, encode and decode random base32 strings.
Project-URL: Repository, https://github.com/inveniosoftware/base32-lib
Author-email: Invenio Software <info@inveniosoftware.org>
License: MIT License
License-File: AUTHORS.rst
License-File: LICENSE
Keywords: base32,identifiers
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.8
Provides-Extra: all
Requires-Dist: pytest-black>=0.6.0; extra == 'all'
Requires-Dist: pytest-cov>=3.0.0; extra == 'all'
Requires-Dist: pytest-isort>=3.0.0; extra == 'all'
Requires-Dist: pytest-pycodestyle>=2.2.0; extra == 'all'
Requires-Dist: pytest-pydocstyle>=2.2.3; extra == 'all'
Requires-Dist: pytest<9.0,>=6.0; extra == 'all'
Requires-Dist: sphinx>=1.4.2; extra == 'all'
Provides-Extra: docs
Requires-Dist: sphinx>=1.4.2; extra == 'docs'
Provides-Extra: tests
Requires-Dist: pytest-black>=0.6.0; extra == 'tests'
Requires-Dist: pytest-cov>=3.0.0; extra == 'tests'
Requires-Dist: pytest-isort>=3.0.0; extra == 'tests'
Requires-Dist: pytest-pycodestyle>=2.2.0; extra == 'tests'
Requires-Dist: pytest-pydocstyle>=2.2.3; extra == 'tests'
Requires-Dist: pytest<9.0,>=6.0; extra == 'tests'
Description-Content-Type: text/x-rst

..
   SPDX-FileCopyrightText: 2019 CERN.
   SPDX-FileCopyrightText: 2019 Northwestern University.
   SPDX-License-Identifier: MIT


=================
base32-lib
=================

.. image:: https://img.shields.io/coveralls/inveniosoftware/base32-lib.svg
        :target: https://coveralls.io/r/inveniosoftware/base32-lib

.. image:: https://img.shields.io/github/tag/inveniosoftware/base32-lib.svg
        :target: https://github.com/inveniosoftware/base32-lib/releases

.. image:: https://img.shields.io/pypi/dm/base32-lib.svg
        :target: https://pypi.python.org/pypi/base32-lib

.. image:: https://img.shields.io/github/license/inveniosoftware/base32-lib.svg
        :target: https://github.com/inveniosoftware/base32-lib/blob/master/LICENSE


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

Usage
=====

.. code-block:: python

    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:

.. code-block:: console

    pip install base32-lib


Development
===========

.. code-block:: console

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

Tests
-----

.. code-block:: console

    pipenv run ./run-tests.sh
