Hi,
I've been using the CspParameter class to read/write RSA parameters that is used for encrypting data.
private string Encrypt(string plainText)
{
try
{
CspParameters cp = new CspParameters();
cp.KeyContainerName = "RSAKeyContainer";
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp); <<< exception occurs here
RSAParameters RSAParams = rsa.ExportParameters(false);
return RSAEncrypt(plainText, RSAParams, false);
}
catch (CryptographicException e)
{
return "";
}
}
The code has been working fine, but recently it started throwing an exception
when I try to instantiate the RSACryptoServiceProvider class. Changing the
KeyContainerName worked for a while, but then the problem came back again.
The error message is "Object already exists". Can anyone explain what's going on ?