zoukankan      html  css  js  c++  java
  • rsa非对称加密

    rsa非对称加密

    #-*-coding:utf-8-*-
    #@author    :vict
    #@Time      :2021-09-17 16:12
    #@File      :newEntryOverClient
    #@software  :PyCharm
    import json
    import requests
    import rsatool
    import time
    import base64
    
    if __name__ == '__main__':
        senddict = {}
        senddict['Id'] = '018001333210917163333001'
        senddict['time'] = time.strftime("%Y%m%d%H%M%S", time.localtime())
        senddict['devNo'] = '112'
        senddict['obuId'] = '111111'
        senddict['vehPlate'] = '云SAD268'
        senddict['color'] = 0
        senddict['vehClass'] = 1
        senddict['weight'] = 2000
        senddict['aixs'] = 2
        senddict['speed'] = 120
        senddict['maxWeight'] = 9999
        senddict['overLimit'] = 9999
        senddict['overLimitRate'] = 0
        senddict['vehLen'] = 100
        senddict['vehWide'] = 100
        senddict['vehHight'] = 100
        senddict['isDJYS'] = 0
        senddict['isRelease'] = 1
        senddict['certNo'] = "32392138502131"
        senddict['isBlackvehicle'] = 2
    
        rsatool = rsatool.RsaTool('rsa_public_key.pem', 'rsa_private_key.pem')
        bts_str = (json.dumps(senddict)).encode()
        crypto_bytes = rsatool.rsa_public_encrypt(bts_str)
        cipher_text = base64.b64encode(crypto_bytes)
        print(cipher_text)
        #rsa非对称加密
        ret = requests.post("http://127.0.0.1:8765/security/WeighingLane/RealTimeWeighingInfo", data=crypto_bytes)
        print(ret.status_code)
        print(type(ret.content))
        print(base64.b64encode(ret.content))
        d_crypto_bytes = rsatool.rsa_private_decrypt(ret.content)
        print(d_crypto_bytes)
        #无加密
        ret = requests.post("http://127.0.0.1:8765/WeighingLane/RealTimeWeighingInfo", data=bts_str)
        print(ret.status_code)
        print(type(ret.content))
    
  • 相关阅读:
    EF生成的SQL语句执行顺序问题。
    关于scope_identity()与 @@IDENTITY
    按条件设置gridcontrol 单元格属性
    DevExpress gridcontrol Master-Detail绑定到对象类型
    dev ChartControl 备忘
    gridcontrol 图片列异步加载
    关于EmitMapper,映射配置
    asp.net Hessian 服务的注册
    XtrasReport 标签打印
    Devexpress + wcf +ef 批量更新处理
  • 原文地址:https://www.cnblogs.com/huanyinglvtuan/p/15543473.html
Copyright © 2011-2022 走看看