当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > .NET中加密和解密的实现方法 3

ASP.NET
ASP.NET 打造互联网未来空间站(3)
ASP.NET 打造互联网未来空间站(4)
Asp.net+Xml开发网络硬盘
ASP.NET中树形图的实现
ASP.NET中Cookie编程的基础知识(1)
ASP.NET中Cookie编程的基础知识(2)
ASP.NET中Cookie编程的基础知识(3)
ASP.NET中Cookie编程的基础知识(4)
ASP.NET中Cookie编程的基础知识(5)
ASP.NET中Cookie编程的基础知识(6)
ASP.NET中Cookie编程简明参考
ASP.NET中数据库的操作初步(1)
ASP.NET中数据库的操作初步(2)
ASP.NET中数据库的操作初步(3)
最佳ASP.NET编程习惯
Microsoft .NET 框架常见问题(一)
Microsoft .NET 框架常见问题(二)
用Visual C#打造个性化的IE浏览器
.NET Compact Framework的强大二维图形引擎
VB.NET如何在没有.NET框架的机器上运行

ASP.NET 中的 .NET中加密和解密的实现方法 3


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 106 ::
收藏到网摘: n/a

//使用客户端的公共密钥加密对称密钥并发送给客。encryptAndSendSymmetricKey(client, rsa, symm);//使用对称密钥加密信息并发送encryptAndSendSecretMessage(client, symm, msg);}catch (Exception e){Console.WriteLine(e.Message);Console.WriteLine(e.StackTrace);}finally{try{client.Close();listener.Stop();}catch{//错误}Console.WriteLine("Server exiting...");}}private static RSAParameters getClientPublicKey(TcpClient client){// 从字节流获取串行化的公共密钥,通过串并转换写入类的实例byte[] buffer = new byte[RSA_KEY_SIZE_BYTES];NetworkStream ns = client.GetStream();MemoryStream ms = new MemoryStream();BinaryFormatter bf = new BinaryFormatter();RSAParameters result;int len = 0;int totalLen = 0;