一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

一个发邮件的例子,涉及MSMQ,RSA,JMAIL

时间:2008-01-12 编辑:简简单单 来源:一聚教程网

 
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();

热门栏目