I know the main answer I am likely to get is why the hell would you want to do that?!
Unfortunately despite my protests I have to do it, even though I know it makes
RSA is built into .NET: System.Security.Cryptography.RSA
.
Encrypting using the public key and decrypting with the private key is one of the most common things people do with asymmetric algorithms, it allows anybody to send you something securely.
If you do it the other way: encrypt using the private key, and decrypt with the public key then it proves the message was sent by the holder of the private key. But because anyone presumably can get hold of the public key, people don't tend to encrypt the whole message, they instead just sign a hash of the data using the private key. Hence RSACryptoServiceProvider
has Sign__
and Verify__
methods to do just that.
Still, there are Encrypt/Decrypt
methods if your partner insists.
Saying that, I've found the Microsoft crypto classes a bit tricky to deal with and lacking in certain areas and much prefer the Bouncy Castle libraries.