Public partial class Form1: Form {private string Estring; private string priKey; private string pubKey; public Form1 () {InitializeComponent (); RSACryptoServiceProvider rsa = new RSACryptoServiceProvider (); priKey = rsa. toXmlString (true); pubKey = rsa. toXmlString (false);} public static string RSAEncrypt (string publickey, string content) {RSACryptoServiceProvider rsa = new RSACryptoServiceProvider (); byte [] cipherbytes; rsa. fromXmlString (publickey); cipherbytes = rsa. encrypt (Encoding. UTF8.GetBytes (content), false); return Convert. toBase64String (cipherbytes);} public static string RSADecrypt (string privateKey, string content) {RSACryptoServiceProvider rsa = new RSACryptoServiceProvider (); byte [] cipherbytes; rsa. fromXmlString (privateKey); cipherbytes = rsa. decrypt (Convert. fromBase64String (content), false); return Encoding. UTF8.GetString (cipherbytes);} private void button#click (object sender, EventArgs e) {Estring = RSAEncrypt (pubKey, "Hi Bob");} private void button2_Click (object sender, EventArgs e) {string DString; DString = RSADecrypt (priKey, Estring);} private void button3_Click (object sender, EventArgs e) {byte [] messagebytes = Encoding. UTF8.GetBytes ("luo"); RSACryptoServiceProvider oRSA = new RSACryptoServiceProvider (); string privatekey = oRSA. toXmlString (true); string publickey = oRSA. toXmlString (false); // the Private Key signature RSACryptoServiceProvider oRSA3 = new RSACryptoServiceProvider (); encrypt (privatekey); byte [] AOutput = oRSA3.SignData (messagebytes, "SHA1 "); // public key verification RSACryptoServiceProvider oRSA4 = new RSACryptoServiceProvider (); oRSA4.FromXmlString (publickey); bool bVerify = oRSA4.VerifyData (messagebytes, "SHA1", AOutput );}}