代码拉取完成,页面将自动刷新
同步操作将从 staugur/Python-SecureHTTP 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
通过使用RSA+AES让HTTP传输更加安全,即C/S架构的加密通信!(Make HTTP transmissions more secure via RSA+AES, encrypted communication for C/S architecture.)
安装(Installation):
# 正式版(Release)
$ pip install -U SecureHTTP
# 开发版(Dev)
$ pip install -U git+https://github.com/staugur/Python-SecureHTTP.git
测试用例(TestCase):
$ git clone https://github.com/staugur/Python-SecureHTTP && cd Python-SecureHTTP
$ make test
示例代码(Examples):
from SecureHTTP import AESEncrypt, AESDecrypt
# 加密后的密文
ciphertext = AESEncrypt('ThisIsASecretKey', 'Hello World!')
# 解密后的明文
plaintext = AESDecrypt("ThisIsASecretKey", ciphertext)
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请求
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)
# 以上四个步骤即完成一次请求/响应
欢迎提交PR、共同开发!
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。