且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 .net 框架中使用先前生成的 RSA 公钥/私钥

更新时间:2023-01-18 09:58:53

要使用现有密钥,您可以使用 ImportParameters-方法:

To use an existing key, you can use the ImportParameters-method:

RSAParameters parameters = new RSAParameters()
parameters.Modulus = // ...
parameters.Exponent = // ...
RSA rsa = new RSACryptoServiceProvider();
rsa.ImportParameters(parameters);
rsa.Encrypt(/*...*/);

您也可以添加私有参数,以便将其用于解密或签名.

You can add the private parameters, too, in order to use it for decrypting or signing.

为了告诉您如何从现有的密钥数据获取参数,我们需要确切地知道它们是如何编码的.尝试向我们展示字符串(如果它是真正的密钥,请将大部分私钥替换为 Xs).

In order to tell you how to get from your existing keydata to the parameters, we need to know exactly how they are encoded. Try showing us the strings (replace most of the private key with Xs if it is a real key).