C#实现简单的实现简单的RSA非对称加密算法示例非对称加密算法示例
本文实例讲述了C#实现简单的RSA非对称加密算法。分享给大家供大家参考,具体如下:
界面控件
namespace RSA算法
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.StrBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.PubKeyBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.PrvKeyBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.EncrypeBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.Str2Box = new System.Windows.Forms.TextBox();
this.CrypeBtn = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// StrBox
//
this.StrBox.Location = new System.Drawing.Point(115, 12);
this.StrBox.Name = "StrBox";
this.StrBox.Size = new System.Drawing.Size(258, 21);
this.StrBox.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(11, 18);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(77, 12);
this.label1.TabIndex = 1;
this.label1.Text = "加密前的明文";
//
// PubKeyBox
//
this.PubKeyBox.Location = new System.Drawing.Point(115, 78);
this.PubKeyBox.Multiline = true;
this.PubKeyBox.Name = "PubKeyBox";
this.PubKeyBox.Size = new System.Drawing.Size(258, 74);
this.PubKeyBox.TabIndex = 2;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(11, 87);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(29, 12);
this.label2.TabIndex = 3;
this.label2.Text = "公钥";