Make HTTP transmissions more secure, encrypted communication for C/S architecture.
Project description
让HTTP传输更加安全,C/S架构的加密通信!(Make HTTP transmissions more secure, encrypted communication for C/S architecture.)
使用概述(Overview)
安装(Installation)
$ pip install -U SecureHTTP
示例代码(Examples)
RSA加密、解密
from SecureHTTP import AESEncrypt, AESDecrypt # 加密后的密文 ciphertext = AESEncrypt('ThisIsASecretKey', 'Hello World!') # 解密后的明文 plaintext = AESDecrypt("ThisIsASecretKey", ciphertext)
AES加密、解密
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加解密示例: 登录时,password使用RSA加密,后端解密
文档(Documentation)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
SecureHTTP-0.2.3.tar.gz
(9.2 kB
view hashes)
Built Distribution
Close
Hashes for SecureHTTP-0.2.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69f02c9e8ccee716a50257014e0e7f4887c6c1e4f480fdac59399acd26a7a44b |
|
MD5 | 33ca32d856e9b251dd0947131ce353fb |
|
BLAKE2b-256 | ffe43868b31098fdddbe826acf903a7dff5a87e6986138328210b3f2c5a1b8e8 |