hybrid-cipher


Namehybrid-cipher JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryHybrid Encryption Mode with Public-Key Encryption and Symmetric Encryption.
upload_time2024-05-22 11:48:01
maintainerZhao JunTao
docs_urlNone
authorZhao JunTao
requires_pythonNone
licenseMIT
keywords hybrid-cipher
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # hybrid-cipher

Hybrid Encryption Mode with Public-Key Encryption and Symmetric Encryption.

## Install

```
pip install hybrid-cipher
```

## 加密原理

### 加密步骤

1. 生成随机32位临时密钥。
2. 使用RSA公钥加密临时密钥。
3. 使用临时密钥及AES GCM加密算法加密数据内容。
4. 把临时密钥的密文及数据密文相关字段拼接在一起,作为整体密文。

### 解密步骤

1. 分割密文为:临时密钥密文、数据密文相关字段。
2. 使用RSA私钥解密临时密钥密文,得到临时密钥明文。
3. 使用临时密钥明文及AES GCM解密算法解密数据密文相关字段,得到数据明文。

## Usage

```
In [1]: from Crypto.PublicKey import RSA
   ...: from hybrid_cipher import HybridCipher
   ...: 
   ...: sk = RSA.generate(1024)

In [2]: 

In [2]: cipher = HybridCipher(sk)

In [3]: cipher.encrypt({"a": "b"})
Out[3]: 'LS8T8hzgCfzo9QzlJ8pO7DD+pSolam9EZIhr35gTSGQayTj2NLqPgx7T8VGbgC2EnAf7fuFN0EXNlljQt1Vg9EyUC8sAMCRCw21zGN/SQttVQFQrETtZndNw/c5pODMVeVFELKnzbw0E50IC3f4mTd38il6O7fQz9SH7zr8Lle0=.tXn5E6vUHLbufPi7gIEFJg+iZDrxOq73q3ds3ZUHFOA=.51hM5vLf4x3nmwlbKRTgwA==.DK5W89RZ9MCl220YqZo5mA==./0O4k+4zIwIGrw=='

In [4]: cipher.decrypt('LS8T8hzgCfzo9QzlJ8pO7DD+pSolam9EZIhr35gTSGQayTj2NLqPgx7T8VGbgC2EnAf7fuFN0EXNlljQt1Vg9EyUC8sAMCRCw21zGN/SQttVQFQrETtZndNw/c5pODMVeVFELKnzbw0E50IC3f4mTd
   ...: 38il6O7fQz9SH7zr8Lle0=.tXn5E6vUHLbufPi7gIEFJg+iZDrxOq73q3ds3ZUHFOA=.51hM5vLf4x3nmwlbKRTgwA==.DK5W89RZ9MCl220YqZo5mA==./0O4k+4zIwIGrw==')
Out[4]: {'a': 'b'}
```

## Release

### v0.1.1

- First release.



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "hybrid-cipher",
    "maintainer": "Zhao JunTao",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "hybrid-cipher",
    "author": "Zhao JunTao",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/fd/c8/4fd3872e5ceb0272d85263f76c07d7e38f67eb50336f1333830efa05b02f/hybrid_cipher-0.1.1.tar.gz",
    "platform": null,
    "description": "# hybrid-cipher\n\nHybrid Encryption Mode with Public-Key Encryption and Symmetric Encryption.\n\n## Install\n\n```\npip install hybrid-cipher\n```\n\n## \u52a0\u5bc6\u539f\u7406\n\n### \u52a0\u5bc6\u6b65\u9aa4\n\n1. \u751f\u6210\u968f\u673a32\u4f4d\u4e34\u65f6\u5bc6\u94a5\u3002\n2. \u4f7f\u7528RSA\u516c\u94a5\u52a0\u5bc6\u4e34\u65f6\u5bc6\u94a5\u3002\n3. \u4f7f\u7528\u4e34\u65f6\u5bc6\u94a5\u53caAES GCM\u52a0\u5bc6\u7b97\u6cd5\u52a0\u5bc6\u6570\u636e\u5185\u5bb9\u3002\n4. \u628a\u4e34\u65f6\u5bc6\u94a5\u7684\u5bc6\u6587\u53ca\u6570\u636e\u5bc6\u6587\u76f8\u5173\u5b57\u6bb5\u62fc\u63a5\u5728\u4e00\u8d77\uff0c\u4f5c\u4e3a\u6574\u4f53\u5bc6\u6587\u3002\n\n### \u89e3\u5bc6\u6b65\u9aa4\n\n1. \u5206\u5272\u5bc6\u6587\u4e3a\uff1a\u4e34\u65f6\u5bc6\u94a5\u5bc6\u6587\u3001\u6570\u636e\u5bc6\u6587\u76f8\u5173\u5b57\u6bb5\u3002\n2. \u4f7f\u7528RSA\u79c1\u94a5\u89e3\u5bc6\u4e34\u65f6\u5bc6\u94a5\u5bc6\u6587\uff0c\u5f97\u5230\u4e34\u65f6\u5bc6\u94a5\u660e\u6587\u3002\n3. \u4f7f\u7528\u4e34\u65f6\u5bc6\u94a5\u660e\u6587\u53caAES GCM\u89e3\u5bc6\u7b97\u6cd5\u89e3\u5bc6\u6570\u636e\u5bc6\u6587\u76f8\u5173\u5b57\u6bb5\uff0c\u5f97\u5230\u6570\u636e\u660e\u6587\u3002\n\n## Usage\n\n```\nIn [1]: from Crypto.PublicKey import RSA\n   ...: from hybrid_cipher import HybridCipher\n   ...: \n   ...: sk = RSA.generate(1024)\n\nIn [2]: \n\nIn [2]: cipher = HybridCipher(sk)\n\nIn [3]: cipher.encrypt({\"a\": \"b\"})\nOut[3]: 'LS8T8hzgCfzo9QzlJ8pO7DD+pSolam9EZIhr35gTSGQayTj2NLqPgx7T8VGbgC2EnAf7fuFN0EXNlljQt1Vg9EyUC8sAMCRCw21zGN/SQttVQFQrETtZndNw/c5pODMVeVFELKnzbw0E50IC3f4mTd38il6O7fQz9SH7zr8Lle0=.tXn5E6vUHLbufPi7gIEFJg+iZDrxOq73q3ds3ZUHFOA=.51hM5vLf4x3nmwlbKRTgwA==.DK5W89RZ9MCl220YqZo5mA==./0O4k+4zIwIGrw=='\n\nIn [4]: cipher.decrypt('LS8T8hzgCfzo9QzlJ8pO7DD+pSolam9EZIhr35gTSGQayTj2NLqPgx7T8VGbgC2EnAf7fuFN0EXNlljQt1Vg9EyUC8sAMCRCw21zGN/SQttVQFQrETtZndNw/c5pODMVeVFELKnzbw0E50IC3f4mTd\n   ...: 38il6O7fQz9SH7zr8Lle0=.tXn5E6vUHLbufPi7gIEFJg+iZDrxOq73q3ds3ZUHFOA=.51hM5vLf4x3nmwlbKRTgwA==.DK5W89RZ9MCl220YqZo5mA==./0O4k+4zIwIGrw==')\nOut[4]: {'a': 'b'}\n```\n\n## Release\n\n### v0.1.1\n\n- First release.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Hybrid Encryption Mode with Public-Key Encryption and Symmetric Encryption.",
    "version": "0.1.1",
    "project_urls": null,
    "split_keywords": [
        "hybrid-cipher"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c450094b98f54e33b71a8acf2789e0f64f2d7fdca9f1cf455cfc5099357b1117",
                "md5": "8163d6009629546ddf0df88a165e8e61",
                "sha256": "22a2a45c5c85f6b0867f948694a59adb221f0c653a661ecb90d6b4910f584583"
            },
            "downloads": -1,
            "filename": "hybrid_cipher-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8163d6009629546ddf0df88a165e8e61",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4485,
            "upload_time": "2024-05-22T11:47:58",
            "upload_time_iso_8601": "2024-05-22T11:47:58.549302Z",
            "url": "https://files.pythonhosted.org/packages/c4/50/094b98f54e33b71a8acf2789e0f64f2d7fdca9f1cf455cfc5099357b1117/hybrid_cipher-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fdc84fd3872e5ceb0272d85263f76c07d7e38f67eb50336f1333830efa05b02f",
                "md5": "a70bfc4e93c6f99ce404f84ad6698f2f",
                "sha256": "4533210ad2923f2348dc5fa5232da20f59b6a07acc9c61d5c1153aba0841a1cb"
            },
            "downloads": -1,
            "filename": "hybrid_cipher-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a70bfc4e93c6f99ce404f84ad6698f2f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4492,
            "upload_time": "2024-05-22T11:48:01",
            "upload_time_iso_8601": "2024-05-22T11:48:01.054571Z",
            "url": "https://files.pythonhosted.org/packages/fd/c8/4fd3872e5ceb0272d85263f76c07d7e38f67eb50336f1333830efa05b02f/hybrid_cipher-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-22 11:48:01",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "hybrid-cipher"
}
        
Elapsed time: 0.21590s