使http传输更加安全,c/s b/s架构的加密通信。

PySecureHTT的Python项目详细描述


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

Build StatusDocumentation StatuscodecovPyPIPyversionsImplementation996.ICU

使用概述(Overview)

安装(Installation):

# 正式版(Release)
$ pip install -U PySecureHTTP
# 开发版(Dev)
$ pip install -U git+git+https://github.com/cisco08/PythonWeb-SecureHTTP@master

示例代码(Examples):

  1. AES加密、解密

    fromSecureHTTPimportAESEncrypt,AESDecrypt# 加密后的密文ciphertext=AESEncrypt('ThisIsASecretKey','Hello World!')# 解密后的明文plaintext=AESDecrypt("ThisIsASecretKey",ciphertext)
  2. RSA加密、解密

    fromSecureHTTPimportRSAEncrypt,RSADecrypt,generate_rsa_keys# 生成密钥对(pubkey,privkey)=generate_rsa_keys(incall=True)# 加密后的密文ciphertext=RSAEncrypt(pubkey,'Hello World!')# 解密后的明文plaintext=RSADecrypt(privkey,ciphertext)
  3. C/S加解密示例:

    # 模拟C/S请求fromSecureHTTPimportEncryptedCommunicationClient,EncryptedCommunicationServer,generate_rsa_keyspost={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)# 以上四个步骤即完成一次请求/响应

说在后面(END)

欢迎提交PR、共同开发!

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java置换相关算法   在Java中读取/打开文本文件   java为什么这段代码不适用于CodeEval?   java如何将日历转换为JSON   从txt文件中读取字符串并将其存储到java中的字符数组中   字符编码Java ResourceBundles umlauts搞砸了   java为什么hashmap会根据总大小而不是填充的存储桶调整大小   java如何将Excel单元格中的数字字符串读取为字符串(而不是数字)?   java Guava的LocalCache无法使用,为什么?   java有没有办法强制JVM在单个处理器或内核上运行   java Eclipse不安装软件   将字节转换为java字符串(可能是汉字)   Java正则表达式:提取函数名   JavaTestNG:如何从多个类中指定测试方法顺序?