我有一个这样的公钥:
BgIAAACkAABSU0ExAAQAAAEAAQCH3cm40A7P6GzlRrDMC1hEgB9kwPYLCei0z/NxnEwzj/brpcmhMXoebyW7GLoAgNaVigi5/+ UMbuXwva9e6WpAZu + 45 + wAuBJGetnlhfhgGWs8WpaE6qYpB94m3UUWdAB5rwSvC4gxHzHcGCk5M3ilNxA5Hk3jcXcvwzum + fHqg = =
如何使用Python用该密钥加密字符串?
我一直在尝试这种变化:
from Crypto.PublicKey import RSA
rsakey = RSA.importKey(key)
但是我一直得到错误ValueError: RSA密钥格式不支持
您需要使用以下内容作为输入:
-----BEGIN PUBLIC KEY-----
BgIAAACkAABSU0ExAAQAAAEAAQCH3cm40A7P6GzlRrDMC1hEgB9kwPYLCei0z/NxnEwzj/brpcmhMXoebyW7GLoAgNaVigi5/+UMbuXwva9e6WpAZu+45a+wAuBJGetnlhfhgGWs8WpaE6qYpB94m3UUWdAB5rwSvC4gxHzHcGCk5M3ilNxA5Hk3jcXcvwzum+fHqg==
-----END PUBLIC KEY-----