Python-SecureHTTP
通过使用RSA+AES让HTTP传输更加安全,即C/S架构的加密通信!(Make HTTP transmissions more secure via RSA+AES, encrypted communication for C/S architecture.)
使用概述(Overview)
安装(Installation):
# 正式版(Release)
$ pip install -U SecureHTTP
# 开发版(Dev)
$ pip install -U git+https://github.com/staugur/Python-SecureHTTP.git@master
测试用例(TestCase):
温馨提示:运行完整测试需要php和go命令!
$ git clone https://github.com/staugur/Python-SecureHTTP && cd Python-SecureHTTP
$ make dev && make test
示例代码(Examples):
AES加密、解密
from SecureHTTP import AESEncrypt, AESDecrypt # 加密后的密文 ciphertext = AESEncrypt('ThisIsASecretKey', 'Hello World!') # 解密后的明文 plaintext = AESDecrypt("ThisIsASecretKey", ciphertext)RSA加密、解密
from SecureHTTP import RSAEncrypt, RSADecrypt, generate_rsa_keys # 生成密钥对 (pubkey, privkey) = generate_rsa_keys(incall=True) # 加密后的密文 ciphertext = RSAEncrypt(pubkey, 'Hello World!') # 解密后的明文 plaintext = RSADecrypt(privkey, ciphertext)C/S加解密示例:点此查看以下模拟代码的真实WEB环境示例
# 模拟C/S请求 from SecureHTTP import EncryptedCommunicationClient, EncryptedCommunicationServer, generate_rsa_keys post = {u'a': 1, u'c': 3, u'b': 2, u'data': ["a", 1, None]} resp = {u'msg': None, u'code': 0} # 生成密钥对 (pubkey, privkey) = generate_rsa_keys(incall=True) # 初始化客户端类 client = EncryptedCommunicationClient(pubkey) # 初始化服务端类 server = EncryptedCommunicationServer(privkey) # NO.1 客户端加密数据 c1 = client.clientEncrypt(post) # NO.2 服务端解密数据 s1 = server.serverDecrypt(c1) # NO.3 服务端返回加密数据 s2 = server.serverEncrypt(resp) # NO.4 客户端获取返回数据并解密 c2 = client.clientDecrypt(s2) # 以上四个步骤即完成一次请求/响应B/S加解密示例:前端使用AES+RSA加密,后端解密
文档(Documentation)
资源(Resources)
说在后面(END)
欢迎提交PR、共同开发!
Metadata
Release files for SecureHTTP 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| SecureHTTP-0.5.0.tar.gz | 10.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| SecureHTTP-0.5.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 22.3 kB
Release files / SecureHTTP-0.5.0.tar.gz
| Download URL | SecureHTTP-0.5.0.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b1a51cb3a6314862d5042013f1df9575ab2f51dccb4f01deaa688f07ef3825f
|
|
BLAKE2b-256 checksum How to use checksums |
8cdc75de31c919fceeff89afe286febc2e7b04a3557c4c8617b86500863b8b2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15rc1
|
Release files / SecureHTTP-0.5.0-py2.py3-none-any.whl
| Download URL | SecureHTTP-0.5.0-py2.py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
7d2c67516d46810fe7ae01782ac094e71f63fac93940add7b9bf6f9dda877d85
|
|
BLAKE2b-256 checksum How to use checksums |
c437c9ac6b1dc12ad47c25ed2aae643dbb07f5d6b6686bfb3c6c71541cbfb18c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15rc1
|