base95


Namebase95 JSON
Version 2.0 PyPI version JSON
download
home_pageNone
SummaryBase95 是一种用 95 个可见的 ASCII 字符(含空格)表示任意二进制数据的编码方法,编码后的信息密度高于 Base64 编码。
upload_time2024-04-19 10:09:59
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords base64 base85 base95
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 项目描述

Base95 是一种用 95 个可见的 ASCII 字符(含空格)表示任意二进制数据的编码方法。

该实现使用了从空格(ASCII 32)到波浪符(ASCII 126)这 95 个字符来编码二进制数据,编码后的信息密度高于 Base64 编码。

# 作者

[江南雨上](mailto:lcctoor@outlook.com)

[主页](https://lcctoor.github.io/arts) \| [Github](https://github.com/lcctoor) \| [PyPi](https://pypi.org/user/lcctoor) \| [微信](https://lcctoor.github.io/arts/arts/ip_static/WeChatQRC.jpg) \| [邮箱](mailto:lcctoor@outlook.com) \| [捐赠](https://lcctoor.github.io/arts/arts/ip_static/DonationQRC-0rmb.jpg)

# Bug提交、功能提议

你可以通过 [Github-Issues](https://github.com/lcctoor/arts/issues)、[微信](https://lcctoor.github.io/arts/arts/ip_static/WeChatQRC.jpg) 与我联系。

# 安装

```
pip install base95
```

# 教程 ([查看美化版](https://lcctoor.github.io/arts/arts/base95) 👈)

本文将以最简洁的方式向你介绍核心知识,而不会让你被繁琐的术语所淹没。

## 导入

```python
from base95 import BaseEncoding
```

## 编码

```python
base95 = BaseEncoding(95)

bytestring: bytes = '黄河之水天上来'.encode('utf8')  # 建构一个字节串

encoded_text: str = base95.encode(bytestring)  # 编码成 Base95
```

## 解码

```python
decoded_bytes: bytes = base95.decode(encoded_text)  # 解码成字节串
```

## 任意进制编码

通过上面的例子,聪明的你一定在想:使用 `BaseEncoding(n)` 是不是可以创建其它进制的编码方法?答案是:是的。

你可以通过 `BaseEncoding(n)` 方式创建 2 ~ 95 进制的编码方法。

例如:

```python
base2 = BaseEncoding(2)
base50 = BaseEncoding(50)
base80 = BaseEncoding(80)
```

## 直接导入常用编码方法

对于一些具有特别意义的编码方法,我们提供了直接导入的方式,而无须使用 `BaseEncoding(n)` 方式创建。

这些编码方法是:

* base95:使用了 ASCII 中的全部(95 个,含空格)可见字符;
* base90:使用除【单引号、双引号、代码号(`)、空格、反斜杠】这 5 个影响阅读体验的字符以外的 90 个字符;
* base62:仅使用 `0~9、a~z、A~Z` 这 62 个字符;
* base10:仅使用 `0~9` 这 10 个字符。

你可以直接导入并使用这些常用的编码方法,例如:

```python
from base95 import base90

base90.encode('黄河之水天上来'.encode('utf8'))
```

当然,你仍然可以通过 `BaseEncoding(90)` 的方式使用这些编码方法,这两种方式是等价的。

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "base95",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "base64, base85, base95",
    "author": null,
    "author_email": "\u6c5f\u5357\u96e8\u4e0a <lcctoor@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/ba/cd/71bf746c4a90c22e72860fc75ec4006edad3579e91050a04e5a057ad26ed/base95-2.0.tar.gz",
    "platform": null,
    "description": "# \u9879\u76ee\u63cf\u8ff0\n\nBase95 \u662f\u4e00\u79cd\u7528 95 \u4e2a\u53ef\u89c1\u7684 ASCII \u5b57\u7b26\uff08\u542b\u7a7a\u683c\uff09\u8868\u793a\u4efb\u610f\u4e8c\u8fdb\u5236\u6570\u636e\u7684\u7f16\u7801\u65b9\u6cd5\u3002\n\n\u8be5\u5b9e\u73b0\u4f7f\u7528\u4e86\u4ece\u7a7a\u683c\uff08ASCII 32\uff09\u5230\u6ce2\u6d6a\u7b26\uff08ASCII 126\uff09\u8fd9 95 \u4e2a\u5b57\u7b26\u6765\u7f16\u7801\u4e8c\u8fdb\u5236\u6570\u636e\uff0c\u7f16\u7801\u540e\u7684\u4fe1\u606f\u5bc6\u5ea6\u9ad8\u4e8e Base64 \u7f16\u7801\u3002\n\n# \u4f5c\u8005\n\n[\u6c5f\u5357\u96e8\u4e0a](mailto:lcctoor@outlook.com)\n\n[\u4e3b\u9875](https://lcctoor.github.io/arts) \\| [Github](https://github.com/lcctoor) \\| [PyPi](https://pypi.org/user/lcctoor) \\| [\u5fae\u4fe1](https://lcctoor.github.io/arts/arts/ip_static/WeChatQRC.jpg) \\| [\u90ae\u7bb1](mailto:lcctoor@outlook.com) \\| [\u6350\u8d60](https://lcctoor.github.io/arts/arts/ip_static/DonationQRC-0rmb.jpg)\n\n# Bug\u63d0\u4ea4\u3001\u529f\u80fd\u63d0\u8bae\n\n\u4f60\u53ef\u4ee5\u901a\u8fc7 [Github-Issues](https://github.com/lcctoor/arts/issues)\u3001[\u5fae\u4fe1](https://lcctoor.github.io/arts/arts/ip_static/WeChatQRC.jpg) \u4e0e\u6211\u8054\u7cfb\u3002\n\n# \u5b89\u88c5\n\n```\npip install base95\n```\n\n# \u6559\u7a0b ([\u67e5\u770b\u7f8e\u5316\u7248](https://lcctoor.github.io/arts/arts/base95) \ud83d\udc48)\n\n\u672c\u6587\u5c06\u4ee5\u6700\u7b80\u6d01\u7684\u65b9\u5f0f\u5411\u4f60\u4ecb\u7ecd\u6838\u5fc3\u77e5\u8bc6\uff0c\u800c\u4e0d\u4f1a\u8ba9\u4f60\u88ab\u7e41\u7410\u7684\u672f\u8bed\u6240\u6df9\u6ca1\u3002\n\n## \u5bfc\u5165\n\n```python\nfrom base95 import BaseEncoding\n```\n\n## \u7f16\u7801\n\n```python\nbase95 = BaseEncoding(95)\n\nbytestring: bytes = '\u9ec4\u6cb3\u4e4b\u6c34\u5929\u4e0a\u6765'.encode('utf8')  # \u5efa\u6784\u4e00\u4e2a\u5b57\u8282\u4e32\n\nencoded_text: str = base95.encode(bytestring)  # \u7f16\u7801\u6210 Base95\n```\n\n## \u89e3\u7801\n\n```python\ndecoded_bytes: bytes = base95.decode(encoded_text)  # \u89e3\u7801\u6210\u5b57\u8282\u4e32\n```\n\n## \u4efb\u610f\u8fdb\u5236\u7f16\u7801\n\n\u901a\u8fc7\u4e0a\u9762\u7684\u4f8b\u5b50\uff0c\u806a\u660e\u7684\u4f60\u4e00\u5b9a\u5728\u60f3\uff1a\u4f7f\u7528 `BaseEncoding(n)` \u662f\u4e0d\u662f\u53ef\u4ee5\u521b\u5efa\u5176\u5b83\u8fdb\u5236\u7684\u7f16\u7801\u65b9\u6cd5\uff1f\u7b54\u6848\u662f\uff1a\u662f\u7684\u3002\n\n\u4f60\u53ef\u4ee5\u901a\u8fc7 `BaseEncoding(n)` \u65b9\u5f0f\u521b\u5efa 2 ~ 95 \u8fdb\u5236\u7684\u7f16\u7801\u65b9\u6cd5\u3002\n\n\u4f8b\u5982\uff1a\n\n```python\nbase2 = BaseEncoding(2)\nbase50 = BaseEncoding(50)\nbase80 = BaseEncoding(80)\n```\n\n## \u76f4\u63a5\u5bfc\u5165\u5e38\u7528\u7f16\u7801\u65b9\u6cd5\n\n\u5bf9\u4e8e\u4e00\u4e9b\u5177\u6709\u7279\u522b\u610f\u4e49\u7684\u7f16\u7801\u65b9\u6cd5\uff0c\u6211\u4eec\u63d0\u4f9b\u4e86\u76f4\u63a5\u5bfc\u5165\u7684\u65b9\u5f0f\uff0c\u800c\u65e0\u987b\u4f7f\u7528 `BaseEncoding(n)` \u65b9\u5f0f\u521b\u5efa\u3002\n\n\u8fd9\u4e9b\u7f16\u7801\u65b9\u6cd5\u662f\uff1a\n\n* base95\uff1a\u4f7f\u7528\u4e86 ASCII \u4e2d\u7684\u5168\u90e8\uff0895 \u4e2a\uff0c\u542b\u7a7a\u683c\uff09\u53ef\u89c1\u5b57\u7b26\uff1b\n* base90\uff1a\u4f7f\u7528\u9664\u3010\u5355\u5f15\u53f7\u3001\u53cc\u5f15\u53f7\u3001\u4ee3\u7801\u53f7(`)\u3001\u7a7a\u683c\u3001\u53cd\u659c\u6760\u3011\u8fd9 5 \u4e2a\u5f71\u54cd\u9605\u8bfb\u4f53\u9a8c\u7684\u5b57\u7b26\u4ee5\u5916\u7684 90 \u4e2a\u5b57\u7b26\uff1b\n* base62\uff1a\u4ec5\u4f7f\u7528 `0~9\u3001a~z\u3001A~Z` \u8fd9 62 \u4e2a\u5b57\u7b26\uff1b\n* base10\uff1a\u4ec5\u4f7f\u7528 `0~9` \u8fd9 10 \u4e2a\u5b57\u7b26\u3002\n\n\u4f60\u53ef\u4ee5\u76f4\u63a5\u5bfc\u5165\u5e76\u4f7f\u7528\u8fd9\u4e9b\u5e38\u7528\u7684\u7f16\u7801\u65b9\u6cd5\uff0c\u4f8b\u5982\uff1a\n\n```python\nfrom base95 import base90\n\nbase90.encode('\u9ec4\u6cb3\u4e4b\u6c34\u5929\u4e0a\u6765'.encode('utf8'))\n```\n\n\u5f53\u7136\uff0c\u4f60\u4ecd\u7136\u53ef\u4ee5\u901a\u8fc7 `BaseEncoding(90)` \u7684\u65b9\u5f0f\u4f7f\u7528\u8fd9\u4e9b\u7f16\u7801\u65b9\u6cd5\uff0c\u8fd9\u4e24\u79cd\u65b9\u5f0f\u662f\u7b49\u4ef7\u7684\u3002\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Base95 \u662f\u4e00\u79cd\u7528 95 \u4e2a\u53ef\u89c1\u7684 ASCII \u5b57\u7b26\uff08\u542b\u7a7a\u683c\uff09\u8868\u793a\u4efb\u610f\u4e8c\u8fdb\u5236\u6570\u636e\u7684\u7f16\u7801\u65b9\u6cd5\uff0c\u7f16\u7801\u540e\u7684\u4fe1\u606f\u5bc6\u5ea6\u9ad8\u4e8e Base64 \u7f16\u7801\u3002",
    "version": "2.0",
    "project_urls": {
        "HomePage": "https://github.com/lcctoor/arts/tree/main/arts/base95"
    },
    "split_keywords": [
        "base64",
        " base85",
        " base95"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4d7044b525e0bd23223a08bfe58e17a3a74db666c84698053025be095f0b5f7a",
                "md5": "5c83522254fb97ae7e77dcdc9a88e1d3",
                "sha256": "71948a89abcd31ecb7c824848ad62f8d5ee2adda1343d3092b3b2eaedde17af5"
            },
            "downloads": -1,
            "filename": "base95-2.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5c83522254fb97ae7e77dcdc9a88e1d3",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 6418,
            "upload_time": "2024-04-19T10:09:56",
            "upload_time_iso_8601": "2024-04-19T10:09:56.102293Z",
            "url": "https://files.pythonhosted.org/packages/4d/70/44b525e0bd23223a08bfe58e17a3a74db666c84698053025be095f0b5f7a/base95-2.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "bacd71bf746c4a90c22e72860fc75ec4006edad3579e91050a04e5a057ad26ed",
                "md5": "ebcbea714a34e3d76f70b3b25af680d2",
                "sha256": "7f1fbc713d62e32540c6da3ee9758cf7bf6dde51274da0cc88304eae6485f0a0"
            },
            "downloads": -1,
            "filename": "base95-2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ebcbea714a34e3d76f70b3b25af680d2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7708,
            "upload_time": "2024-04-19T10:09:59",
            "upload_time_iso_8601": "2024-04-19T10:09:59.027674Z",
            "url": "https://files.pythonhosted.org/packages/ba/cd/71bf746c4a90c22e72860fc75ec4006edad3579e91050a04e5a057ad26ed/base95-2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-19 10:09:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lcctoor",
    "github_project": "arts",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "base95"
}
        
Elapsed time: 0.23415s