encrypt256


Nameencrypt256 JSON
Version 1.8.6.2 PyPI version JSON
download
home_pageNone
Summarystr 型和 bytes 型数据加密器
upload_time2023-10-27 07:40:00
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords encrypt256 encrypt aes pycryptodome crypto
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 项目描述

str 型和 bytes 型数据加密器。

1、底层加密算法为 AES-CBC-256。

2、加密时,会自动创建随机 salt、随机 iv、原始明文的校验值,并把校验值添加到密文中。

3、解密时,会自动根据校验值校验“解密得到的明文”与“原始明文”是否一致。

# 作者信息

昵称:lcctoor.com

[主页](https://lcctoor.github.io/arts/) \| [微信](https://lcctoor.github.io/arts/arts/static/static-files/WeChatQRC.jpg) \| [Github](https://github.com/lcctoor) \| [PyPi](https://pypi.org/user/lcctoor) \| [Python交流群](https://lcctoor.github.io/arts/arts/static/static-files/PythonWeChatGroupQRC.jpg) \| [邮箱](mailto:lcctoor@outlook.com) \| [域名](http://lcctoor.com) \| [捐赠](https://lcctoor.github.io/arts/arts/static/static-files/DonationQRC-0rmb.jpg)

# Bug提交、功能提议

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

# 安装

```
pip install encrypt256
```

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

#### 导入

```python
from encrypt256 import Encrypt256
```

#### 创建加密器

```python
password1 = 123456789  # 支持int型密钥
password2 = '黄河之水天上来'  # 支持str型密钥
password3 = '床前明月光'.encode('utf8')  # 支持bytes型密钥

enctool = Encrypt256(password1)  # 创建加密器
```

#### 加密

```python
p1 = '人生自古谁五死'  # 可加密str型数据
p2 = '莎士比亚'.encode('utf8')  # 可加密bytes型数据

c1 = enctool.encrypt(p1)
c2 = enctool.encrypt(p2)
```

#### 解密

```python
r1 = enctool.decrypt(c1)
r2 = enctool.decrypt(c2)

assert p1 == r1
assert p2 == r2
assert type(p1) is type(r1)
assert type(p2) is type(r2)
```

当发生以下情况时,会解密失败并报错:

1、密钥错误。

2、由于密文被篡改,导致 AES 算法解密失败。

3、由于密文被篡改,虽然 AES 算法解密成功,但校验值错误。

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "encrypt256",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "encrypt256,encrypt,AES,pycryptodome,Crypto",
    "author": null,
    "author_email": "\"lcctoor.com\" <lcctoor@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/d3/3a/afa3047d53696117e1052ea37d9480050b38c8f2d2e44cbeafed1f0b1367/encrypt256-1.8.6.2.tar.gz",
    "platform": null,
    "description": "# \u9879\u76ee\u63cf\u8ff0\n\nstr \u578b\u548c bytes \u578b\u6570\u636e\u52a0\u5bc6\u5668\u3002\n\n1\u3001\u5e95\u5c42\u52a0\u5bc6\u7b97\u6cd5\u4e3a AES-CBC-256\u3002\n\n2\u3001\u52a0\u5bc6\u65f6\uff0c\u4f1a\u81ea\u52a8\u521b\u5efa\u968f\u673a salt\u3001\u968f\u673a iv\u3001\u539f\u59cb\u660e\u6587\u7684\u6821\u9a8c\u503c\uff0c\u5e76\u628a\u6821\u9a8c\u503c\u6dfb\u52a0\u5230\u5bc6\u6587\u4e2d\u3002\n\n3\u3001\u89e3\u5bc6\u65f6\uff0c\u4f1a\u81ea\u52a8\u6839\u636e\u6821\u9a8c\u503c\u6821\u9a8c\u201c\u89e3\u5bc6\u5f97\u5230\u7684\u660e\u6587\u201d\u4e0e\u201c\u539f\u59cb\u660e\u6587\u201d\u662f\u5426\u4e00\u81f4\u3002\n\n# \u4f5c\u8005\u4fe1\u606f\n\n\u6635\u79f0\uff1alcctoor.com\n\n[\u4e3b\u9875](https://lcctoor.github.io/arts/) \\| [\u5fae\u4fe1](https://lcctoor.github.io/arts/arts/static/static-files/WeChatQRC.jpg) \\| [Github](https://github.com/lcctoor) \\| [PyPi](https://pypi.org/user/lcctoor) \\| [Python\u4ea4\u6d41\u7fa4](https://lcctoor.github.io/arts/arts/static/static-files/PythonWeChatGroupQRC.jpg) \\| [\u90ae\u7bb1](mailto:lcctoor@outlook.com) \\| [\u57df\u540d](http://lcctoor.com) \\| [\u6350\u8d60](https://lcctoor.github.io/arts/arts/static/static-files/DonationQRC-0rmb.jpg)\n\n# Bug\u63d0\u4ea4\u3001\u529f\u80fd\u63d0\u8bae\n\n\u60a8\u53ef\u4ee5\u901a\u8fc7 [Github-Issues](https://github.com/lcctoor/arts/issues)\u3001[\u5fae\u4fe1](https://lcctoor.github.io/arts/arts/static/static-files/WeChatQRC.jpg) \u4e0e\u6211\u8054\u7cfb\u3002\n\n# \u5b89\u88c5\n\n```\npip install encrypt256\n```\n\n# \u6559\u7a0b ([\u67e5\u770b\u7f8e\u5316\u7248](https://lcctoor.github.io/arts/?pk=encrypt256)\ud83d\udc48)\n\n#### \u5bfc\u5165\n\n```python\nfrom encrypt256 import Encrypt256\n```\n\n#### \u521b\u5efa\u52a0\u5bc6\u5668\n\n```python\npassword1 = 123456789  # \u652f\u6301int\u578b\u5bc6\u94a5\npassword2 = '\u9ec4\u6cb3\u4e4b\u6c34\u5929\u4e0a\u6765'  # \u652f\u6301str\u578b\u5bc6\u94a5\npassword3 = '\u5e8a\u524d\u660e\u6708\u5149'.encode('utf8')  # \u652f\u6301bytes\u578b\u5bc6\u94a5\n\nenctool = Encrypt256(password1)  # \u521b\u5efa\u52a0\u5bc6\u5668\n```\n\n#### \u52a0\u5bc6\n\n```python\np1 = '\u4eba\u751f\u81ea\u53e4\u8c01\u4e94\u6b7b'  # \u53ef\u52a0\u5bc6str\u578b\u6570\u636e\np2 = '\u838e\u58eb\u6bd4\u4e9a'.encode('utf8')  # \u53ef\u52a0\u5bc6bytes\u578b\u6570\u636e\n\nc1 = enctool.encrypt(p1)\nc2 = enctool.encrypt(p2)\n```\n\n#### \u89e3\u5bc6\n\n```python\nr1 = enctool.decrypt(c1)\nr2 = enctool.decrypt(c2)\n\nassert p1 == r1\nassert p2 == r2\nassert type(p1) is type(r1)\nassert type(p2) is type(r2)\n```\n\n\u5f53\u53d1\u751f\u4ee5\u4e0b\u60c5\u51b5\u65f6\uff0c\u4f1a\u89e3\u5bc6\u5931\u8d25\u5e76\u62a5\u9519\uff1a\n\n1\u3001\u5bc6\u94a5\u9519\u8bef\u3002\n\n2\u3001\u7531\u4e8e\u5bc6\u6587\u88ab\u7be1\u6539\uff0c\u5bfc\u81f4 AES \u7b97\u6cd5\u89e3\u5bc6\u5931\u8d25\u3002\n\n3\u3001\u7531\u4e8e\u5bc6\u6587\u88ab\u7be1\u6539\uff0c\u867d\u7136 AES \u7b97\u6cd5\u89e3\u5bc6\u6210\u529f\uff0c\u4f46\u6821\u9a8c\u503c\u9519\u8bef\u3002\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "str \u578b\u548c bytes \u578b\u6570\u636e\u52a0\u5bc6\u5668",
    "version": "1.8.6.2",
    "project_urls": {
        "HomePage": "https://github.com/lcctoor/arts/tree/main/arts/encrypt256"
    },
    "split_keywords": [
        "encrypt256",
        "encrypt",
        "aes",
        "pycryptodome",
        "crypto"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4c70f7b220967ae40e1b73f085adde8c5e0ca778df67c3a7a9235388d4cdbf21",
                "md5": "cb12a9a5eea0f854c35572ee7fd56c65",
                "sha256": "3ff1d205b7c619c1dfb911883a8e781a0c8a53edab670f4eabd58a0aff97a4db"
            },
            "downloads": -1,
            "filename": "encrypt256-1.8.6.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cb12a9a5eea0f854c35572ee7fd56c65",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 6231,
            "upload_time": "2023-10-27T07:39:56",
            "upload_time_iso_8601": "2023-10-27T07:39:56.865984Z",
            "url": "https://files.pythonhosted.org/packages/4c/70/f7b220967ae40e1b73f085adde8c5e0ca778df67c3a7a9235388d4cdbf21/encrypt256-1.8.6.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d33aafa3047d53696117e1052ea37d9480050b38c8f2d2e44cbeafed1f0b1367",
                "md5": "1ee15f08a66cc4a7055486825b4eab34",
                "sha256": "8e79c9057dfcb05aff4f95d55b06c4d9a79e34f60790bc398a8a778252110e51"
            },
            "downloads": -1,
            "filename": "encrypt256-1.8.6.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1ee15f08a66cc4a7055486825b4eab34",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6134,
            "upload_time": "2023-10-27T07:40:00",
            "upload_time_iso_8601": "2023-10-27T07:40:00.078855Z",
            "url": "https://files.pythonhosted.org/packages/d3/3a/afa3047d53696117e1052ea37d9480050b38c8f2d2e44cbeafed1f0b1367/encrypt256-1.8.6.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-27 07:40:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lcctoor",
    "github_project": "arts",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "encrypt256"
}
        
Elapsed time: 0.13012s