欢迎来到天天文库
浏览记录
ID:57686717
大小:238.50 KB
页数:13页
时间:2020-09-01
《C#计算机网络编程实验十四.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验十四一、实验目的(1)数据加密基本算法(2)DES编程技术与应用(3)RSA的编程技术与应用(4)混合加密网络传输技术与实现二、预习内容(1)具备数据数据安全传输系统的分析与设计能力(2)掌握基于DES加密传输的程序设计与实现能力三、实验内容本次实验是基于RSA-DES进行网络加密传输程序设计。四、实验结果服务器端usingSystem;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Net;usingSystem.Net.Sockets;usingSystem.IO;usingSystem.Se
2、curity.Cryptography;usingSystem.Threading;namespacejiami_Server{publicpartialclassForm1:Form{privateSocketsocket;privateSocketclientSocket;privateThreadthread;privatestringSAKey;privateRSACryptoServiceProviderrsa;privatebyte[]SAIV={0xFE,0xA1,0x23,0x4E,0xBC,0x1B,0x32,0xEF};publicForm1
3、(){InitializeComponent();CheckForIllegalCrossThreadCalls=false;this.listBoxState.Items.Clear();this.richTextBoxAccept.Text="";this.txtSend.Text="";}privatevoidbtnStart_Click(objectsender,EventArgse){try{SAKey=this.txtpwd.Text;if(SAKey.Length!=8){MessageBox.Show("请输入8位密码");this.Close(
4、);}IPEndPointserver=newIPEndPoint(IPAddress.Parse(this.textBoxIP.Text),Int32.Parse(this.textBoxPort.Text));this.socket=newSocket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);this.socket.Bind(server);this.socket.Listen(10);this.clientSocket=socket.Accept();this.listB
5、oxState.Items.Add("与客户"+clientSocket.RemoteEndPoint.ToString()+"建立连接");this.btnStart.Enabled=false;getClientPublicKey();encryptAndSendSymmetricKey();}catch{MessageBox.Show("");}thread=newThread(newThreadStart(AcceptMessage));thread.Start();}privatevoidbtnStop_Click(objectsender,Event
6、Argse){try{this.socket.Shutdown(SocketShutdown.Both);this.socket.Close();this.clientSocket.Close();this.thread.Abort();this.btnStart.Enabled=true;this.btnStop.Enabled=false;}catch(Exceptionee){MessageBox.Show(ee.Message);}}privatevoidbtnSend_Click(objectsender,EventArgse){try{if(this
7、.txtSend.Text==""){MessageBox.Show("无法送信息");return;}stringstr=EncryptDES(this.txtSend.Text);TransData.SendVarData(clientSocket,Encoding.UTF8.GetBytes(str));this.richTextBoxAccept.AppendText("发送:"+this.txtSend.Text+Environment.NewLine);this.txtSend.Text="";}catch(Exceptionex){MessageB
8、ox.Show(ex.M
此文档下载收益归作者所有