# ----------密码加密-------------
def rsa_encrypt(password, publicKey):
"""使用公钥进行加密"""
cipher = Cipher_pkcs1_v1_5.new(RSA.importKey(publicKey))
cipher_text = base64.b64encode(cipher.encrypt(password.encode())).decode()
return cipher_text
def getPubKey(getPublicKeyUrl):
# getPublicKeyUrl = 'http://xx.xx.xx/admin/getPublicKey'
res = requests.get(getPublicKeyUrl)
rs = json.loads(res.text)
return rs['result']
def encode(password, getPublicKeyUrl):
pubKey = '-----BEGIN PUBLIC KEY-----\n'
pubKey = pubKey + getPubKey(getPublicKeyUrl)
pubKey = pubKey + '\n-----END PUBLIC KEY-----'
return rsa_encrypt(password, pubKey)
# ----------------------------------
class SysOp:
def __init__(self):
self.host = "http://xx.xx.xx"
self.session = requests.session()
de
09-14
441
08-24
5635
10-16
10-16
07-19
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交