如果对你有帮助可以给我点个赞呗_。
非对称加密之RSA
RSA有两把密钥公钥(public key)私钥(private key),用公钥加密只能用私钥解密,用私钥加密只能用公钥解密
import base64
from Crypto import Random
from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_v1_5
text = '{"code":200,"data":{"apts":[]},"message":"","success":true}'
# 初始化RSA对象, 伪随机数生成器
rsa = RSA.generate(1024, Random.new().read)
# 私钥
private_key = rsa.exportKey()
# 公钥
public_key = rsa.publickey().exportKey()
print(private_key.decode('utf-8'))
print(public_key.decode