【发布时间】:2013-05-18 16:33:12
【问题描述】:
我有以下代码。
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
//Save the public key information to an RSAParameters structure.
RSAParameters RSAKeyInfo = RSA.ExportParameters(true);
byte[] toEncryptData = Encoding.ASCII.GetBytes("hello world");
byte[] encryptedRSA = RSAEncrypt(toEncryptData, RSAKeyInfo, false);
string EncryptedResult = System.Text.Encoding.Default.GetString(encryptedRSA);
byte[] decryptedRSA = RSADecrypt(encryptedRSA, RSAKeyInfo, false);
string originalResult = System.Text.Encoding.Default.GetString(decryptedRSA);
return userDetails.ToString();
当我使用 RSAEncrypt 方法时,它采用参数“RSAKeyInfo”(用于加密的公钥和用于解密的私钥)。
如何获取私钥和公钥的值,该方法用于加密和解密。
谢谢,
【问题讨论】: