Name | makkus.bases JSON |
Version |
0.2.4
JSON |
| download |
home_page | https://github.com/hashberg-io/bases |
Summary | Forked from the original author until they incorporate latest fixes; Python library for general Base-N encodings. |
upload_time | 2023-11-28 09:39:16 |
maintainer | |
docs_url | None |
author | hashberg |
requires_python | >=3.7 |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
bases: A Python library for Base-N encodings
============================================
.. image:: https://img.shields.io/badge/python-3.7+-green.svg
:target: https://docs.python.org/3.7/
:alt: Python versions
.. image:: https://img.shields.io/pypi/v/bases.svg
:target: https://pypi.python.org/pypi/bases/
:alt: PyPI version
.. image:: https://img.shields.io/pypi/status/bases.svg
:target: https://pypi.python.org/pypi/bases/
:alt: PyPI status
.. image:: http://www.mypy-lang.org/static/mypy_badge.svg
:target: https://github.com/python/mypy
:alt: Checked with Mypy
.. image:: https://readthedocs.org/projects/bases/badge/?version=latest
:target: https://bases.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://github.com/hashberg-io/bases/actions/workflows/python-pytest.yml/badge.svg
:target: https://github.com/hashberg-io/bases/actions/workflows/python-pytest.yml
:alt: Python package status
.. image:: https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square
:target: https://github.com/RichardLitt/standard-readme
:alt: standard-readme compliant
Bases provides a customisable, parametric implementation of several common styles of Base-N encoding, covering all cases appearing in the `multibase specification <https://github.com/multiformats/multibase>`_ (except for proquints).
This is a temporary fork of the original project to be used until the original project incorporates a bug fix to work with newer versions of the 'typing_extensions' dependency.
Bug: https://github.com/hashberg-io/typing-validation/issues/1
.. contents::
Install
-------
You can install the latest release from `PyPI <https://pypi.org/project/bases/>`_ as follows:
.. code-block:: console
$ pip install --upgrade bases
Usage
-----
We suggest you import bases as follows:
>>> import bases
Below are some basic usage examples, to get you started: for detailed documentation, see https://bases.readthedocs.io/
Base encoding objects
^^^^^^^^^^^^^^^^^^^^^
>>> from bases import base32
>>> base32
FixcharBaseEncoding(
StringAlphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',
case_sensitive=False),
pad_char='=', padding='include')
Encoding
^^^^^^^^
>>> b = bytes([70, 98, 190, 187, 66, 224, 178])
>>> base32.encode(b)
'IZRL5O2C4CZA===='
Decoding
^^^^^^^^
>>> s = 'IZRL5O2C4CZA===='
>>> base32.decode(s)
b'Fb\xbe\xbbB\xe0\xb2'
>>> list(base32.decode(s))
[70, 98, 190, 187, 66, 224, 178]
Case/padding variations
^^^^^^^^^^^^^^^^^^^^^^^
>>> b = bytes([70, 98, 190, 187, 66, 224, 178])
>>> base32.encode(b)
'IZRL5O2C4CZA===='
>>> base32lower = base32.lower()
>>> base32lower
FixcharBaseEncoding(
StringAlphabet('abcdefghijklmnopqrstuvwxyz234567',
case_sensitive=False),
pad_char='=', padding='include')
>>> base32lower.encode(b)
'izrl5o2c4cza===='
>>> base32nopad = base32.nopad()
>>> base32nopad.encode(b)
'IZRL5O2C4CZA'
Case sensitivity variations
^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>> s = 'IZRL5O2C4CZA===='
>>> base32lower.decode(s)
b'Fb\xbe\xbbB\xe0\xb2'
>>> base32lower_casesensitive = base32lower.with_case_sensitivity(True)
>>> base32lower_casesensitive.decode(s)
bases.encoding.errors.NonAlphabeticCharError: Invalid character 'I'
encountered for alphabet StringAlphabet('abcdefghijklmnopqrstuvwxyz234567').
Custom base encodings
^^^^^^^^^^^^^^^^^^^^^
>>> base4 = bases.make("0123", kind="zeropad-enc", block_nchars=4)
>>> base4
ZeropadBaseEncoding(StringAlphabet('0123'), block_nchars=4)
API
---
For the full API documentation, see https://bases.readthedocs.io/
Contributing
------------
Please see `<CONTRIBUTING.md>`_.
License
-------
`MIT © Hashberg Ltd. <LICENSE>`_
Raw data
{
"_id": null,
"home_page": "https://github.com/hashberg-io/bases",
"name": "makkus.bases",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "hashberg",
"author_email": "sg495@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/5a/c8/9f50bf8011966dda46d00ab97a14a868756265cd691c3b524f3702af3ef8/makkus.bases-0.2.4.tar.gz",
"platform": null,
"description": "bases: A Python library for Base-N encodings\n============================================\n\n.. image:: https://img.shields.io/badge/python-3.7+-green.svg\n :target: https://docs.python.org/3.7/\n :alt: Python versions\n\n.. image:: https://img.shields.io/pypi/v/bases.svg\n :target: https://pypi.python.org/pypi/bases/\n :alt: PyPI version\n\n.. image:: https://img.shields.io/pypi/status/bases.svg\n :target: https://pypi.python.org/pypi/bases/\n :alt: PyPI status\n\n.. image:: http://www.mypy-lang.org/static/mypy_badge.svg\n :target: https://github.com/python/mypy\n :alt: Checked with Mypy\n \n.. image:: https://readthedocs.org/projects/bases/badge/?version=latest\n :target: https://bases.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n.. image:: https://github.com/hashberg-io/bases/actions/workflows/python-pytest.yml/badge.svg\n :target: https://github.com/hashberg-io/bases/actions/workflows/python-pytest.yml\n :alt: Python package status\n\n.. image:: https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square\n :target: https://github.com/RichardLitt/standard-readme\n :alt: standard-readme compliant\n\n\nBases provides a customisable, parametric implementation of several common styles of Base-N encoding, covering all cases appearing in the `multibase specification <https://github.com/multiformats/multibase>`_ (except for proquints).\n\nThis is a temporary fork of the original project to be used until the original project incorporates a bug fix to work with newer versions of the 'typing_extensions' dependency.\n\nBug: https://github.com/hashberg-io/typing-validation/issues/1\n\n.. contents::\n\n\nInstall\n-------\n\nYou can install the latest release from `PyPI <https://pypi.org/project/bases/>`_ as follows:\n\n.. code-block:: console\n\n $ pip install --upgrade bases\n\n\nUsage\n-----\n\nWe suggest you import bases as follows:\n\n>>> import bases\n\n\nBelow are some basic usage examples, to get you started: for detailed documentation, see https://bases.readthedocs.io/\n\n\nBase encoding objects\n^^^^^^^^^^^^^^^^^^^^^\n\n>>> from bases import base32\n>>> base32\nFixcharBaseEncoding(\n StringAlphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',\n case_sensitive=False),\n pad_char='=', padding='include')\n\n\nEncoding\n^^^^^^^^\n\n>>> b = bytes([70, 98, 190, 187, 66, 224, 178])\n>>> base32.encode(b)\n'IZRL5O2C4CZA===='\n\n\nDecoding\n^^^^^^^^\n\n>>> s = 'IZRL5O2C4CZA===='\n>>> base32.decode(s)\nb'Fb\\xbe\\xbbB\\xe0\\xb2'\n>>> list(base32.decode(s))\n[70, 98, 190, 187, 66, 224, 178]\n\n\nCase/padding variations\n^^^^^^^^^^^^^^^^^^^^^^^\n\n>>> b = bytes([70, 98, 190, 187, 66, 224, 178])\n>>> base32.encode(b)\n'IZRL5O2C4CZA===='\n>>> base32lower = base32.lower()\n>>> base32lower\nFixcharBaseEncoding(\n StringAlphabet('abcdefghijklmnopqrstuvwxyz234567',\n case_sensitive=False),\n pad_char='=', padding='include')\n>>> base32lower.encode(b)\n'izrl5o2c4cza===='\n>>> base32nopad = base32.nopad()\n>>> base32nopad.encode(b)\n'IZRL5O2C4CZA'\n\n\nCase sensitivity variations\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n>>> s = 'IZRL5O2C4CZA===='\n>>> base32lower.decode(s)\nb'Fb\\xbe\\xbbB\\xe0\\xb2'\n>>> base32lower_casesensitive = base32lower.with_case_sensitivity(True)\n>>> base32lower_casesensitive.decode(s)\nbases.encoding.errors.NonAlphabeticCharError: Invalid character 'I'\nencountered for alphabet StringAlphabet('abcdefghijklmnopqrstuvwxyz234567').\n\n\nCustom base encodings\n^^^^^^^^^^^^^^^^^^^^^\n\n>>> base4 = bases.make(\"0123\", kind=\"zeropad-enc\", block_nchars=4)\n>>> base4\nZeropadBaseEncoding(StringAlphabet('0123'), block_nchars=4)\n\n\n\nAPI\n---\n\nFor the full API documentation, see https://bases.readthedocs.io/\n\n\nContributing\n------------\n\nPlease see `<CONTRIBUTING.md>`_.\n\n\nLicense\n-------\n\n`MIT \u00a9 Hashberg Ltd. <LICENSE>`_\n",
"bugtrack_url": null,
"license": "",
"summary": "Forked from the original author until they incorporate latest fixes; Python library for general Base-N encodings.",
"version": "0.2.4",
"project_urls": {
"Bug Tracker": "https://github.com/hashberg-io/bases/issues",
"Homepage": "https://github.com/hashberg-io/bases"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1c2a916b36830a472621bfaa8729bfea975de1471e306a4743a503e1bcc6c94d",
"md5": "06fbbc237b92382c958b1e4d61acc1f3",
"sha256": "4e2b519ce3c0bd7fef587f1474b735487388378cc511954236b4343aeb98f059"
},
"downloads": -1,
"filename": "makkus.bases-0.2.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "06fbbc237b92382c958b1e4d61acc1f3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 35811,
"upload_time": "2023-11-28T09:39:14",
"upload_time_iso_8601": "2023-11-28T09:39:14.365751Z",
"url": "https://files.pythonhosted.org/packages/1c/2a/916b36830a472621bfaa8729bfea975de1471e306a4743a503e1bcc6c94d/makkus.bases-0.2.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5ac89f50bf8011966dda46d00ab97a14a868756265cd691c3b524f3702af3ef8",
"md5": "f68aac4649c06f4f93cb4157eba04d8a",
"sha256": "46c9b1c5a104f6bd94183f9a9d4f28466657970479fb3194bf5d9c298100e6a8"
},
"downloads": -1,
"filename": "makkus.bases-0.2.4.tar.gz",
"has_sig": false,
"md5_digest": "f68aac4649c06f4f93cb4157eba04d8a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 55446,
"upload_time": "2023-11-28T09:39:16",
"upload_time_iso_8601": "2023-11-28T09:39:16.005332Z",
"url": "https://files.pythonhosted.org/packages/5a/c8/9f50bf8011966dda46d00ab97a14a868756265cd691c3b524f3702af3ef8/makkus.bases-0.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-28 09:39:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hashberg-io",
"github_project": "bases",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "makkus.bases"
}