I have been playing about with an RSA encryption / decryption application, trying to get my head round how it works as I will be wanting to implement it into an asp.net web payment application I am building for my dissertation.
I downloaded a simple Console example app. which works fine, and have been trying to reuse this code in a Windows Form Appication to simulate passing data from local > to server > and back... but for some reason I can not decrypt the encrypted text. When stepping through the code I can see that the 128 encryped data gets passed to the Decrypt() method, but for some reason it keeps jumping to the catch...! Any ideas?
Could it be because im making a new instance of the RSACryptoServiceProvider? Ive attachd both projects to make things easier...
Code: Select all
namespace encryptTut
{
public sealed class RSAclass
{
internal static void RSADecrypt(byte[] encryptedData,RSAParameters rSAParameters,bool p)
{
try
{
byte[] decryptedData;
using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider())
{
RSA.ImportParameters(rSAParameters);
decryptedData = RSA.Decrypt(encryptedData, p); //<<<<<<<< SKIPS TO CATCH HERE...?
}
Form2 serverFrm = new Form2();
serverFrm.displayMsg(decryptedData);
}
catch (CryptographicException)
{
// ToDo:
}
}
}
}