1.先生成公钥密钥
RSACryptoServiceProvider crypt=new RSACryptoServiceProvider();
string publickey=crypt.ToXmlString(false);//(公钥)
string privatekey=crypt.ToXmlString(true);
crypt.Clear();
StreamWriter one=new StreamWriter(@"c:a.txt",true,UTF8Encoding.UTF8);
one.Write(publickey);
StreamWriter two=new StreamWriter(@"c:.txt",true,UTF8Encoding.UTF8);
two.Write(privatekey);
one.Flush();
two.Flush();
one.Close();
two.Close();
Console.WriteLine("成功保存公匙和密匙!");
2.对信息加密,然后用通过队列发送信息
string from=TextBoxFrom.Text+DropDownList2.SelectedValue;
string sub=textBoxSub.Text;
string bodys=TextBoxBody.Text;
string pwd=TextBoxPwd.Text;
StreamReader sr = new StreamReader(@"c:a.txt",UTF8Encoding.UTF8);
string readpublickey = sr.ReadToEnd();
sr.Close();
RSACryptoServiceProvider crypt=new RSACryptoServiceProvider();
UTF8Encoding enc=new UTF8Encoding();