C编写的MD5AES等算法的加密解密

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

郑州轻工业学院本科实验报告设计题目:数据加密解密学生姓名:李镇宇系别:计算机与通信工程学院专业:网络运维与安全班级:13-01学号:541307110121指导教师:吉星、程立辉2016年4月12日目录1目的.....................................................................................................................................32实验内容.......................................................................................................................33实验步骤.......................................................................................................................43.1Form窗体...............................................................................................................43.2AES窗体.................................................................................................................73.3DES窗体................................................................................................................83.4MD5窗体.............................................................................................................103.5RC2窗体...............................................................................................................113.6RSA窗体..............................................................................................................133.7TripleDES窗体..............................................................................................154实验结果.....................................................................................................................174.1MD5加密、及其异常措施...................................................................174.2DES加密解密、及其异常措施........................................................184.3TripleDES加密解密、及其异常措施.........................................204.4RC2加密解密、及其异常措施........................................................224.5AES加密解密、及其异常措施........................................................244.6RSA加密解密、及其异常措施.......................................................261目的数据加密技术是网络中最基本的安全技术,主要是通过对网络中传输的信息进行数据加密来保障其安全性,这是一种主动安全防御策略,用很小的代价即可为信息提供相当大的安全保护。2实验内容系统基本功能描述如下:1、实现DES算法加密与解密功能。2、实现TripleDES算法加密与解密功能。3、实现MD5算法加密功能。4、实现RC2算法加密与解密功能。5、实现TripleDES算法加密与解密功能。6、实现RSA算法加密与解密功能。3实验步骤3.1Form窗体六个菜单栏:MD5加密,DES加密解密,TripleDES加密解密,RC2加密解密,AES加密解密,RSA加密解密,分别对应相应的算法。代码:usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;usingSystem.Security.Cryptography;namespace_21_Li{publicpartialclass数据加密解密:Form{public数据加密解密(){InitializeComponent();}privatevoiddES加密ToolStripMenuItem_Click(objectsender,EventArgse){DESdes=newDES();des.MdiParent=this;des.Show();}privatevoidrSA加密解密ToolStripMenuItem_Click(objectsender,EventArgse){RSArsa=newRSA();rsa.MdiParent=this;rsa.Show();}privatevoidmD5加密ToolStripMenuItem_Click(objectsender,EventArgse){MD5md5=newMD5();md5.MdiParent=this;md5.Show();}privatevoidtripleDES加密解密ToolStripMenuItem_Click(objectsender,EventArgse){TripleDEStripdes=newTripleDES();tripdes.MdiParent=this;tripdes.Show();}privatevoidrC2加密解密ToolStripMenuItem_Click(objectsender,EventArgse){RC2rc2=newRC2();rc2.MdiParent=this;rc2.Show();}privatevoidaES加密解密ToolStripMenuItem_Click(objectsender,EventArgse){AESaes=newAES();aes.MdiParent=this;aes.Show();}}}3.2AES窗体控件:四个Lable,四个Textbox,两个Button关键代码:privatevoidbutton1_Click(objectsender,EventArgse){try{textBox3.Text=Security.AESEncrypt(textBox1.Text,textBox2.Text);}catch(Exceptionex){MessageBox.Show(ex.Message);}}privatevoidbutton2_Click(objectsender,EventArgse){try{textBox4.Text=Security.AESDecrypt(textBox3.Text,textBox2.Text);}catch(Exceptionex){MessageBox.Show(ex.Message);}}3.3DES窗体控件:四个Lable,四个Textbox,两个Button关键代码:privatevoidbutton1_Click(objectsender,EventArgse)//加密{try{keyDES=textBox2.Text;encryptedData=textBox1.Text;//明文textBox3.Text=Security.DESEncrypt(encryptedData,keyDES);}catch(Exceptionex){MessageBox.Show(ex.Message);}}privatevoidbutton2_Click(objectsender,EventArgse)//解密{try{keyDES=textBox2.Text;decryptedData=textBox3.Text;textBox4.Text=Security.DESDecrypt(decryptedData,keyDES);}catch(Exceptionex){MessageBox.Show(ex.Message);}}3.4MD5窗体控件:两个Lable,两个Textbox,一个Button关键代码:stringencryptedData;//明文,stringdecryptedData;//密文privatevoidbutton1_Click(objectsender,EventArgse){try{encryptedData=textBox1.Text;decryptedData=Security.MD5Encrypt(encryptedData);textBox2.Text=decryptedData;}catch(Exceptionex){MessageBox.Show(ex.Message);}}3.5RC2窗体控件:四个Lable,四个Textbox,两个Button关键代码:privatevoidbutton1_Click(objectsender,EventArgse)//加密{try{textBox3.Text=Security.RC2Encrypt(textBox1.Text,textBox2.Text);}catch(Exceptionex){MessageBox.Show(ex.Message);}}privatevoidbutton2_Click(objectsender,EventArgse)//解密{try{textBox4.Text=Security.RC2Decrypt(textBox3.Text,textBox2.Text);}catch(Exceptionex){MessageBox.Show(ex.Message);}}3.6RSA窗体控件:四个Lable,四个Textbox,三个Button关键代码:RSACryptoServiceProviderrsa;byte[]Data;byte[]encryptedData;//密文byte[]decryptedData;privatevoidbutton1_Click_1(objectsender,EventArgse){///产生RSA密钥rsa=newRSACryptoServiceProvider();textBox4.Text=rsa.ToXmlString(false);}privatevoidbutton2_Click_1(objectsender,EventArgse){//RSA加密try{Data=Encoding.UTF8.GetBytes(textBox1.Text);encryptedData=rsa.Encry

1 / 26
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功