base2048


Namebase2048 JSON
Version 0.1.3 PyPI version JSON
download
home_pageNone
SummaryBinary encoding with Base2048 in Rust.
upload_time2022-09-26 21:50:16
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT
keywords base2048 base64 base-encoding encoding decoding
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Base 2048   [![pypi_badge]][pypi_url] [![versions]][pypi_url]

[build_badge]: https://github.com/ionite34/base2048/actions/workflows/build.yml/badge.svg
[build_url]: https://github.com/ionite34/base2048/actions/workflows/build.yml
[versions]: https://img.shields.io/pypi/pyversions/base2048
[pypi_badge]: https://badge.fury.io/py/base2048.svg
[pypi_url]: https://pypi.org/project/base2048/
[twitter_count]: https://developer.twitter.com/en/docs/basics/counting-characters
[rs_base]: https://github.com/LLFourn/rust-base2048
[bmp]: https://unicode.org/roadmaps/bmp/

[rtl]: https://wikipedia.org/wiki/Right-to-left_mark

[![build_badge]][build_url]
[![Rust Tests](https://github.com/ionite34/base2048/actions/workflows/rust-test.yml/badge.svg)](https://github.com/ionite34/base2048/actions/workflows/rust-test.yml)
[![Python Tests](https://github.com/ionite34/base2048/actions/workflows/py-test.yml/badge.svg)](https://github.com/ionite34/base2048/actions/workflows/py-test.yml)

[![codecov](https://codecov.io/gh/ionite34/base2048/branch/main/graph/badge.svg?token=1Qdx8w3zoy)](https://codecov.io/gh/ionite34/base2048)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/ionite34/base2048/main.svg)](https://results.pre-commit.ci/latest/github/ionite34/base2048/main)

### When Base 64 is not enough

Allows up to 11 bits of data per unicode character as counted by
social media and chat platforms such as [Twitter][twitter_count] and Discord.

Uses a limited charset within the [Basic Multilingual Plane][bmp].

Based on, and uses a compatible encoding table with the Rust crate [rust-base2048][rs_base].

### - Charset displayable on most locales and platforms
### - No control sequences, punctuation, quotes, or [RTL][rtl] characters

## Getting Started
```shell
pip install base2048
```

```python
import base2048

base2048.encode(b'Hello!')
# => 'ϓțƘ໐µ'

base2048.decode('ϓțƘ໐µ')
# => b'Hello!'
```

### Up to 2x less counted characters compared to Base 64

```python
import zlib
import base64

import base2048

string = ('🐍 🦀' * 1000 + '🐕' * 1000).encode()
data = zlib.compress(string)

b64_data = base64.b64encode(data)
# => b'eJztxrEJACAQBLBVHNUFBBvr75zvRvgxBEkRSGqvkbozIiIiIiIiIiIiIiIiIiIiIiJf5wAAAABvNbM+EOk='
len(b64_data)
# => 84

b2048_data = base2048.encode(data)
# => 'ը྿Ԧҩ২ŀΏਬйཬΙāಽႩԷ࿋ႬॴŒǔ०яχσǑňॷβǑňॷβǑňॷβǯၰØØÀձӿօĴ༎'
len(b2048_data)
# => 46

unpacked = zlib.decompress(base2048.decode(b2048_data)).decode()
len(unpacked)
# => 4000
unpacked[2000:2002]
# => '🦀🐍'
```

### Decode errors are provided with a character-position of failure

```python
----> base2048.decode('༗ǥԢΝĒϧǰ༎ǥ')

DecodeError: Unexpected character 8: ['ǥ'] after termination sequence 7: ['༎']
```
- To catch the error, use either `base2048.DecodeError` or its base exception, `ValueError`.
```python
import base2048

try:
    base2048.decode('🤔')
except base2048.DecodeError as e:
    print(e)
```

## License
The code in this project is released under the [MIT License](LICENSE).

## Related and prior works
> Javascript - [base2048](https://github.com/qntm/base2048)

> Rust - [rust-base2048][rs_base]


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "base2048",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "base2048,base64,base-encoding,encoding,decoding",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/00/a5/2c630c47316f6bf0a2a0fc920f7b09f012bb53ee20baac6172ec3a030cdc/base2048-0.1.3.tar.gz",
    "platform": null,
    "description": "# Base 2048   [![pypi_badge]][pypi_url] [![versions]][pypi_url]\n\n[build_badge]: https://github.com/ionite34/base2048/actions/workflows/build.yml/badge.svg\n[build_url]: https://github.com/ionite34/base2048/actions/workflows/build.yml\n[versions]: https://img.shields.io/pypi/pyversions/base2048\n[pypi_badge]: https://badge.fury.io/py/base2048.svg\n[pypi_url]: https://pypi.org/project/base2048/\n[twitter_count]: https://developer.twitter.com/en/docs/basics/counting-characters\n[rs_base]: https://github.com/LLFourn/rust-base2048\n[bmp]: https://unicode.org/roadmaps/bmp/\n\n[rtl]: https://wikipedia.org/wiki/Right-to-left_mark\n\n[![build_badge]][build_url]\n[![Rust Tests](https://github.com/ionite34/base2048/actions/workflows/rust-test.yml/badge.svg)](https://github.com/ionite34/base2048/actions/workflows/rust-test.yml)\n[![Python Tests](https://github.com/ionite34/base2048/actions/workflows/py-test.yml/badge.svg)](https://github.com/ionite34/base2048/actions/workflows/py-test.yml)\n\n[![codecov](https://codecov.io/gh/ionite34/base2048/branch/main/graph/badge.svg?token=1Qdx8w3zoy)](https://codecov.io/gh/ionite34/base2048)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/ionite34/base2048/main.svg)](https://results.pre-commit.ci/latest/github/ionite34/base2048/main)\n\n### When Base 64 is not enough\n\nAllows up to 11 bits of data per unicode character as counted by\nsocial media and chat platforms such as [Twitter][twitter_count] and Discord.\n\nUses a limited charset within the [Basic Multilingual Plane][bmp].\n\nBased on, and uses a compatible encoding table with the Rust crate [rust-base2048][rs_base].\n\n### - Charset displayable on most locales and platforms\n### - No control sequences, punctuation, quotes, or [RTL][rtl] characters\n\n## Getting Started\n```shell\npip install base2048\n```\n\n```python\nimport base2048\n\nbase2048.encode(b'Hello!')\n# => '\u03d3\u021b\u0198\u0ed0\u00b5'\n\nbase2048.decode('\u03d3\u021b\u0198\u0ed0\u00b5')\n# => b'Hello!'\n```\n\n### Up to 2x less counted characters compared to Base 64\n\n```python\nimport zlib\nimport base64\n\nimport base2048\n\nstring = ('\ud83d\udc0d \ud83e\udd80' * 1000 + '\ud83d\udc15' * 1000).encode()\ndata = zlib.compress(string)\n\nb64_data = base64.b64encode(data)\n# => b'eJztxrEJACAQBLBVHNUFBBvr75zvRvgxBEkRSGqvkbozIiIiIiIiIiIiIiIiIiIiIiJf5wAAAABvNbM+EOk='\nlen(b64_data)\n# => 84\n\nb2048_data = base2048.encode(data)\n# => '\u0568\u0fbf\u0526\u04a9\u09e8\u0140\u038f\u0a2c\u0439\u0f6c\u0399\u0101\u0cbd\u10a9\u0537\u0fcb\u10ac\u0974\u0152\u01d4\u0966\u044f\u03c7\u03c3\u01d1\u0148\u0977\u03b2\u01d1\u0148\u0977\u03b2\u01d1\u0148\u0977\u03b2\u01ef\u1070\u00d8\u00d8\u00c0\u0571\u04ff\u0585\u0134\u0f0e'\nlen(b2048_data)\n# => 46\n\nunpacked = zlib.decompress(base2048.decode(b2048_data)).decode()\nlen(unpacked)\n# => 4000\nunpacked[2000:2002]\n# => '\ud83e\udd80\ud83d\udc0d'\n```\n\n### Decode errors are provided with a character-position of failure\n\n```python\n----> base2048.decode('\u0f17\u01e5\u0522\u039d\u0112\u03e7\u01f0\u0f0e\u01e5')\n\nDecodeError: Unexpected character 8: ['\u01e5'] after termination sequence 7: ['\u0f0e']\n```\n- To catch the error, use either `base2048.DecodeError` or its base exception, `ValueError`.\n```python\nimport base2048\n\ntry:\n    base2048.decode('\ud83e\udd14')\nexcept base2048.DecodeError as e:\n    print(e)\n```\n\n## License\nThe code in this project is released under the [MIT License](LICENSE).\n\n## Related and prior works\n> Javascript - [base2048](https://github.com/qntm/base2048)\n\n> Rust - [rust-base2048][rs_base]\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Binary encoding with Base2048 in Rust.",
    "version": "0.1.3",
    "project_urls": null,
    "split_keywords": [
        "base2048",
        "base64",
        "base-encoding",
        "encoding",
        "decoding"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "38be47723c2a1cf051c2f302be4dd42f847cf50fb7141569aedf8ae834e06a10",
                "md5": "d32450bf90e86585ef5598ca1a7453fc",
                "sha256": "a99289d9594300e55f04fa95a009f24d25d101160818c0be13e56edd9e4ca5c5"
            },
            "downloads": -1,
            "filename": "base2048-0.1.3-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl",
            "has_sig": false,
            "md5_digest": "d32450bf90e86585ef5598ca1a7453fc",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": ">=3.7",
            "size": 448191,
            "upload_time": "2022-09-26T21:50:11",
            "upload_time_iso_8601": "2022-09-26T21:50:11.200035Z",
            "url": "https://files.pythonhosted.org/packages/38/be/47723c2a1cf051c2f302be4dd42f847cf50fb7141569aedf8ae834e06a10/base2048-0.1.3-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "448c1a3e859adbe3ae8f3d7c589abfd5983bd3d707b6197c369eb8e56a25cedd",
                "md5": "02563dee5c614ba214514018b58dc692",
                "sha256": "ad23081619ae06cd7de156252303a865e571bf0527f18272bedaad0f9d431164"
            },
            "downloads": -1,
            "filename": "base2048-0.1.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "02563dee5c614ba214514018b58dc692",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": ">=3.7",
            "size": 1011385,
            "upload_time": "2022-09-26T21:50:13",
            "upload_time_iso_8601": "2022-09-26T21:50:13.879864Z",
            "url": "https://files.pythonhosted.org/packages/44/8c/1a3e859adbe3ae8f3d7c589abfd5983bd3d707b6197c369eb8e56a25cedd/base2048-0.1.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "346fe234bd2c89d714340a8389ebd2e313b30d87eef6cadebe12d852c671662a",
                "md5": "cfa7ffe9926aa2de7ac2a62845820456",
                "sha256": "d1aefd5ee3bee6a6999e38fc01e6ec9cf788d72a5df28b54d8656e51b4a24a9b"
            },
            "downloads": -1,
            "filename": "base2048-0.1.3-cp37-abi3-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "cfa7ffe9926aa2de7ac2a62845820456",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": ">=3.7",
            "size": 122941,
            "upload_time": "2022-09-26T21:50:15",
            "upload_time_iso_8601": "2022-09-26T21:50:15.227478Z",
            "url": "https://files.pythonhosted.org/packages/34/6f/e234bd2c89d714340a8389ebd2e313b30d87eef6cadebe12d852c671662a/base2048-0.1.3-cp37-abi3-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "00a52c630c47316f6bf0a2a0fc920f7b09f012bb53ee20baac6172ec3a030cdc",
                "md5": "bb821f5ec1c2713352769bd34651daba",
                "sha256": "51d9eeae723b8aa84d9721211ca3b62a20cb2b884efbf53b61b3c3a7c440969d"
            },
            "downloads": -1,
            "filename": "base2048-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "bb821f5ec1c2713352769bd34651daba",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 91401,
            "upload_time": "2022-09-26T21:50:16",
            "upload_time_iso_8601": "2022-09-26T21:50:16.358658Z",
            "url": "https://files.pythonhosted.org/packages/00/a5/2c630c47316f6bf0a2a0fc920f7b09f012bb53ee20baac6172ec3a030cdc/base2048-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-09-26 21:50:16",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "base2048"
}
        
Elapsed time: 0.14075s