信息安全与密码学上机报告 - 图文(8)

2019-08-02 01:07

RSA对刚才的加密密钥进行加密。

8.2算法程序

8.2.1 算法功能类代码

using System;

using System.Collections.Generic; using System.Linq; using System.Text;

using System.Threading.Tasks;

using System.Security.Cryptography; using System.IO; using System.Xml;

using System.Management; using Microsoft.Win32;

namespace mimaxue46.leiclass {

class RSA {

///

/// RSA加密 ///

///

public string RSAEncrypt(string publickey, string content) {

publickey =

@\9z7SVju8s0X4gZ6AzZTn06jzWOgyPRV54Q4I0DCYadWW4Ze3e+BOtwgVU1Og3qHKn8vygoj40J6U85Z/PTJu3hN1m75Zr195ju7g9v4Hk=AQAB\;

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); byte[] cipherbytes;

rsa.FromXmlString(publickey);

cipherbytes = rsa.Encrypt(Encoding.UTF8.GetBytes(content), false);

return Convert.ToBase64String(cipherbytes); }

///

/// RSA解密 ///

///

public string RSADecrypt(string privatekey, string content) {

privatekey =

@\9z7SVju8s0X4gZ6AzZTn06jzWOgyPRV54Q4I0DCYadWW4Ze3e+BOtwgVU1Og3qHKn8vygoj40J6U85Z/PTJu3hN1m75Zr195ju7g9v4Hk=AQAB

/hf2dnK7rNfl3lbqghWcpFdu778hUpIEBixCDL5WiBtpkZdpSw90aERmHJYaW2RGvGRi6zSftLh00KHsPcNUMw==

6Cn/jOLrPapDTEp1Fkq+uz++1Do0eeX7HYqi9rY29CqShzCeI7LEYOoSwYuAJ3xA/DuCdQENPSoJ9KFbO4Wsow==ga1rHIJro8e/yhxjrKYo/nqc5ICQGhrpMNlPkD9n3CjZVPOISkWF7FzUHEzDANeJfkZhcZa21z24aG3rKo5Qnw==MNGsCB8rYlMsRZ2ek2pyQwO7h/sZT8y5ilO9wu08Dwnot/7UMiOEQfDWstY3w5XQQHnvC9WFyCfP4h4QBissyw==EG02S7SADhH1EVT9DD0Z62Y0uY7gIYvxX/uq+IzKSCwB8M2G7Qv9xgZQaQlLpCaeKbux3Y59hHM+KpamGL19Kg==vmaYHEbPAgOJvaEXQl+t8DQKFT1fudEysTy31LTyXjGu6XiltXXHUuZaa2IPyHgBz0Nd7znwsW/S44iql0Fen1kzKioEL3svANui63O3o5xdDeExVM6zOf1wUUh/oldovPweChyoAdMtUzgvCbJk1sYDJf++Nr0FeNW1RB1XG30=\;

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); byte[] cipherbytes;

rsa.FromXmlString(privatekey);

35

cipherbytes = rsa.Decrypt(Convert.FromBase64String(content), false);

return Encoding.UTF8.GetString(cipherbytes); } } }

8.2.2 算法窗体代码

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Threading.Tasks; using System.Windows.Forms; using mimaxue46.leiclass;

namespace mimaxue46.FormsClass {

public partial class RSA : Form {

public RSA() {

InitializeComponent(); }

mimaxue46.leiclass.RSA F = new leiclass.RSA();

private void button1_Click(object sender, EventArgs e) {

if (textBox2.Text == \ || textBox2.Text == null) {

MessageBox.Show(\请输入秘钥\); } else {

textBox3.Text = F.RSAEncrypt(textBox2.Text, textBox1.Text); } }

private void button3_Click(object sender, EventArgs e) {

textBox4.Text = textBox3.Text; }

private void button2_Click(object sender, EventArgs e) {

if (textBox6.Text == \ || textBox6.Text == null) {

MessageBox.Show(\请输入秘钥\); } else {

textBox5.Text = F.RSADecrypt(textBox6.Text, textBox4.Text); } }

private void RSA_Load(object sender, EventArgs e) {

36

} } }

8.3运行界面

37

9 PGP加密软件的应用

9.1软件介绍

PGP(Pretty Good Privacy),是一个基于RSA公钥加密体系的邮件加密软件。可以用它对邮

件保密以防止非授权者阅读,它还能对邮件加上数字签名从而使收信人可以确认邮件的发送者,并能确信邮件没有被篡改。它可以提供一种安全的通讯方式,而事先并不需要任何保密的渠道用来传递密匙。它采用了一种RSA和传统加密的杂合算法,用于数字签名的邮件文摘算法,加密前压缩等,还有一个良好的人机工程设计。它的功能强大,有很快的速度。而且它的源代码是免费的

9.2安装过程及主要界面

38

39


信息安全与密码学上机报告 - 图文(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2018年白刚玉行业现状及发展趋势分析(目录)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: