UnicodeEncoding ByteConverter = new UnicodeEncoding(); byte[] dataToEncrypt = ByteConverter.GetBytes("Hello there"); byte[] encryptedData; byte[] decryptedData; //Create a new instance of RSACryptoServiceProvider to generate //public and private key data. //CspParameters param = new CspParameters( using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider()) { //Pass the data to ENCRYPT, the public key information RSA.FromXmlString(SelectedCertificate.PublicKey.Key.ToXmlString(false)); encryptedData = RSA.Encrypt(dataToEncrypt, false); //Pass the data to DECRYPT, the private key information RSA.FromXmlString(SelectedCertificate.PrivateKey.ToXmlString(false)); decryptedData = RSA.Decrypt(encryptedData, false); //Display the decrypted plaintext }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)