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))
    
  • 相关阅读:
    js(四) 全选/全不选和反选
    js(三) ajax异步局部刷新技术底层代码实现
    js(二) 实现省市联动(json)
    接口
    内部类
    封装
    Static关键字
    this关键字
    带参数的方法
    abstract关键字
  • 原文地址:https://www.cnblogs.com/huanyinglvtuan/p/15543473.html
Copyright © 2011-2022 走看看