本文介绍了CryptographicException:未知错误“80007005”。调用RSACryptoServiceProvider.Decrypt()在.NET精简框架时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用的RSACryptoServiceProvider
来加密/解密。加密工作正常,但解密
方法抛出一个异常的消息:
I am trying to use the RSACryptoServiceProvider
to encrypt/decrypt. Encrypting works fine, but the Decrypt
method throws an exception with the message:
未知错误80007005。
Unknown Error '80007005'.
这是在code:
Byte[] plainData = encoding.GetBytes(plainText);
Byte[] encryptedData;
RSAParameters rsap1;
Byte[] decryptedData;
using (RSACryptoServiceProvider rsa1 = new RSACryptoServiceProvider())
{
encryptedData = rsa1.Encrypt(plainData, false);
rsap1 = rsa1.ExportParameters(false);
}
using (RSACryptoServiceProvider rsa2 = new RSACryptoServiceProvider())
{
rsa2.ImportParameters(rsap1);
decryptedData = rsa2.Decrypt(encryptedData, false);
}
decryptedText = encoding.GetString(decryptedData, 0, decryptedData.Length);
任何人是否知道一种解决方法吗?
Is anyone aware of a workaround?
谢谢!
推荐答案
修正了code!我想我并不需要指定容器毕竟...
Fixed the code! I guess I do not need to specify a container after all...
Byte[] plainData = encoding.GetBytes(plainText);
Byte[] encryptedData;
Byte[] decryptedData;
using (RSACryptoServiceProvider rsa1 = new RSACryptoServiceProvider())
{
RSAParameters rsap1 = rsa1.ExportParameters(false);
using (RSACryptoServiceProvider rsa2 = new RSACryptoServiceProvider())
{
rsa2.ImportParameters(rsap1);
encryptedData = rsa2.Encrypt(plainData, false);
}
decryptedData = rsa1.Decrypt(encryptedData, false);
}
decryptedText = encoding.GetString(decryptedData, 0, decryptedData.Length);
这篇关于CryptographicException:未知错误“80007005”。调用RSACryptoServiceProvider.Decrypt()在.NET精简框架时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!