C编写的MD5AES等算法的加密解密讲解Word格式.docx

上传人:b****6 文档编号:20079726 上传时间:2023-01-16 格式:DOCX 页数:21 大小:516.86KB
下载 相关 举报
C编写的MD5AES等算法的加密解密讲解Word格式.docx_第1页
第1页 / 共21页
C编写的MD5AES等算法的加密解密讲解Word格式.docx_第2页
第2页 / 共21页
C编写的MD5AES等算法的加密解密讲解Word格式.docx_第3页
第3页 / 共21页
C编写的MD5AES等算法的加密解密讲解Word格式.docx_第4页
第4页 / 共21页
C编写的MD5AES等算法的加密解密讲解Word格式.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

C编写的MD5AES等算法的加密解密讲解Word格式.docx

《C编写的MD5AES等算法的加密解密讲解Word格式.docx》由会员分享,可在线阅读,更多相关《C编写的MD5AES等算法的加密解密讲解Word格式.docx(21页珍藏版)》请在冰豆网上搜索。

C编写的MD5AES等算法的加密解密讲解Word格式.docx

学号:

541307110121

指导教师:

吉星、程立辉

2016年4月12日

1目的

数据加密技术是网络中最基本的安全技术,主要是通过对网络中传输的信息进行数据加密来保障其安全性,这是一种主动安全防御策略,用很小的代价即可为信息提供相当大的安全保护。

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)

textBox4.Text=Security.AESDecrypt(textBox3.Text,textBox2.Text);

3.3DES窗体

privatevoidbutton1_Click(objectsender,EventArgse)//加密

keyDES=textBox2.Text;

encryptedData=textBox1.Text;

//明文

textBox3.Text=Security.DESEncrypt(encryptedData,keyDES);

MessageBox.Show(ex.Message);

}

privatevoidbutton2_Click(objectsender,EventArgse)//解密

decryptedData=textBox3.Text;

textBox4.Text=Security.DESDecrypt(decryptedData,keyDES);

catch(Exceptionex)

3.4MD5窗体

两个Lable,两个Textbox,一个Button

stringencryptedData;

//明文,

stringdecryptedData;

//密文

privatevoidbutton1_Click(objectsender,EventArgse)

decryptedData=Security.MD5Encrypt(encryptedData);

textBox2.Text=decryptedData;

catch(Exceptionex){MessageBox.Show(ex.Message);

3.5RC2窗体

textBox3.Text=Security.RC2Encrypt(textBox1.Text,textBox2.Text);

textBox4.Text=Security.RC2Decrypt(textBox3.Text,textBox2.Text);

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加密

Data=Encoding.UTF8.GetBytes(textBox1.Text);

encryptedData=rsa.Encrypt(Data,false);

textBox2.Text=Encoding.UTF8.GetString(encryptedData);

privatevoidbutton3_Click_1(objectsender,EventArgse)

{//RSA解密

decryptedData=rsa.Decrypt(encryptedData,false);

textBox3.Text=Encoding.UTF8.GetString(decryptedData);

3.7TripleDES窗体

四个Lable,六个Textbox,两个Button

stringm_strEncrypt,m_strDecrypt;

privatevoidbutton1_Click(objectsender,EventArgse)//加密

m_strEncrypt=Security.DESEncrypt(textBox1.Text,textBox2.Text);

m_strEncrypt=Security.DESEncrypt(m_strEncrypt,textBox3.Text);

textBox5.Text=Security.DESEncrypt(m_strEncrypt,textBox4.Text);

m_strDecrypt=Security.DESDecrypt(textBox5.Text,textBox4.Text);

m_strDecrypt=Security.DESDecrypt(m_strDecrypt,textBox3.Text);

m_strDecrypt=Security.DESDecrypt(m_strDecrypt,textBox2.Text);

textBox6.Text=m_strDecrypt;

4实验结果

4.1MD5加密、及其异常措施

加密时没有输入被加密信息,抛出异常提示:

4.2DES加密解密、及其异常措施

加密时没有输入密钥,抛出异常提示:

输入密钥长度不符合要求,抛出异常提示:

4.3TripleDES加密解密、及其异常措施

4.4RC2加密解密、及其异常措施

4.5AES加密解密、及其异常措施

4.6RSA加密解密、及其异常措施

没有生成RSA密钥,直接来加密,抛出异常提示:

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 解决方案

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1