I am working on a project which involves RSA, and I am trying to get familiar with the RSA C# library.
I have successfully created key pairs, encrypted with the recievers public key, and decrypted with the recipients private key. This provides confidentiality.
RSA is supposed to be able to use both keys for either encryption or decryption. That is, I can encrypt with my own private key, and the recipient kan then decrypt with my public key. This does not provide confidentiality, but authentication, which I'm sure readers of this forum know.
I get an error when i try to do rsa.Decrypt without feeding the rsa component with my private key. I suppose I could null-ify some XML elements but I find it probable that it won't work.
How can I perform this operation with the C# library? I have also seen SignData, and SignHash. I guess perhaps these can be used. I can't really understand the difference between them though.
Please fill me in, any help is greatly appreciated!
Below is some code I use.
all the best BendikM
public static class Cryptography
public static RSACryptoServiceProvider rsa;
//Assign parameters to the RSACryptoService. This is called upon all encryptions / decryptions
private static void AssignParameter()
With SignData it computes the hash of the data you pass in and encrypts that with the private key. VeryfiyData then takes the hash of the data you pass in, decrypts the encrypted hash you pass in with the public key, then compares the two hashes. If the hashes are the same, the data is verified, else it's not.