Author: dgupta.sw | Posted on: 2/27/2009 9:04:05 AM | Views : 255

I'm using 'RSACryptoServiceProvider' for encyption/decrypiton. It breaks sometime during decryption, not all the time. I don't understand the reason for it, i tried some possible cause like
assign permission to Crypto folder under user/applicationData, clearing machine key but didn't work for me.



The Decryption code, i'm using:


RSACryptoServiceProvider rsaProvider = new RSACryptoServiceProvider();

string privateKey = "";

rsaProvider.FromXmlString(privateKey);

byte[] DecryptedBytes = rsaProvider.Decrypt("DataToDecrypt", false);

rsaProvider.Clear();

UnicodeEncoding ByteConverter = new UnicodeEncoding();

return (ByteConverter.GetString(DecryptedBytes));




The exception:


Type: System.Security.Cryptography.CryptographicException

Message: The system cannot find the file specified.

StackTrace: at System.Security.Cryptograp ...

Go to the complete details ...