我有在 Crypto++ 中创建的 DER 编码的 RSA 密钥对以及密码。它们是 Base64Encoded 字符串。我首先将数据从 Base64 解码为字节数组,但我不确定如何将它们加载到RSACryptoServiceProvider
.
static void Main()
{
string pbkeystr = "mypublickey";
string pvkeystr = "myprivatekey";
string cipherstr = "mycipher";
byte[] pbkey = Convert.FromBase64String(pbkeystr);
byte[] pvkey = Convert.FromBase64String(pvkeystr);
byte[] cipher = Convert.FromBase64String(cipherstr);
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
//Set keys here..
//Decrypt the cipher using private key
rsa.Decrypt(pvkey, false);
}
没有设置键的功能。我发现的唯一东西是ImportParameters
方法,它采用RSAParameters
由p
, q
, n
, 模数, 指数等组成的类。我无权访问这些。
有什么办法可以将键加载为字符串?如何将密钥加载到RSACryptoServiceProvider
?