# -*- coding: utf-8 -*- # by dl from Crypto.PublicKey import RSA from Crypto.Signature import PKCS1_v1_5 from Crypto.Hash import SHA from Crypto.Hash import MD5 import base64 loanPrivatekey = '-----BEGIN RSA PRIVATE KEY-----\n私钥\n-----END RSA PRIVATE KEY-----' data='待加密字符串' rsakey = RSA.importKey(loanPrivatekey) signer = PKCS1_v1_5.new(rsakey) digest = MD5.new() # 如果用的是SHA # digest = SHA.new() digest.update(data.encode()) sign = signer.sign(digest) # base64加密 Sign = base64.b64encode(sign) print(Sign)
python3 签名 sha md5
最新推荐文章于 2024-08-08 08:57:17 发布