rsa是目前互聯網主流加密方式,方式爲私鑰加密,公鑰解密或公鑰加密,私鑰解密,由私鑰能推倒出公鑰,反過來,由公鑰不能推倒出私鑰,如果沒有私鑰得話是不能解密的,安全級別極高。
rsa加密相同內容每次的結果都是不一樣的。
下面是python實現rsa加密的代碼:
import base64
import rsa
pubkey = rsa.PublicKey.load_pkcs1_openssl_pem(' 加密公鑰 ')
#公鑰加密
crypto = rsa.encrypt(b'加密文本', pubkey)
crypto_text= base64.b64encode(crypto).decode('utf-8')