1 Star 0 Fork 11

流风一剑1990 / Python-SecureHTTP

forked from staugur / Python-SecureHTTP 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Python-SecureHTTP

通过使用RSA+AES让HTTP传输更加安全,即C/S架构的加密通信!(Make HTTP transmissions more secure via RSA+AES, encrypted communication for C/S architecture.)

Build Status Documentation Status codecov PyPI Pyversions Implementation

使用概述(Overview)

安装(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):

  1. RSA加密、解密
from SecureHTTP import AESEncrypt, AESDecrypt
# 加密后的密文
ciphertext = AESEncrypt('ThisIsASecretKey', 'Hello World!')
# 解密后的明文
plaintext = AESDecrypt("ThisIsASecretKey", ciphertext)
  1. 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)
  1. 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)
# 以上四个步骤即完成一次请求/响应
  1. B/S加解密示例:登录时,password使用RSA加密,后端解密

文档(Documentation)

资源(Resources)

说在后面(END)

欢迎提交PR、共同开发!

MIT License Copyright (c) 2019 Mr.tao Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

通过使用RSA+AES让HTTP传输更加安全,即C/S架构的加密通信 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/liufengyijian/Python-SecureHTTP.git
git@gitee.com:liufengyijian/Python-SecureHTTP.git
liufengyijian
Python-SecureHTTP
Python-SecureHTTP
master

搜索帮助