📄 asymmetricencryption.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace CryptographyExamplesInCS
{
/// <summary>
/// Summary description for AsymmetricEncryption.
/// </summary>
public class AsymmetricEncryption : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtProvider;
private System.Windows.Forms.TextBox txtPassword;
private System.Windows.Forms.TextBox txtUserId;
private System.Windows.Forms.TextBox txtDatabase;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox txtServer;
private AsymmetricExample crypto = new AsymmetricExample();
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public AsymmetricEncryption()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
public void Encrypt()
{
crypto.Database = this.txtDatabase.Text;
crypto.Password = this.txtPassword.Text;
crypto.Provider = this.txtProvider.Text;
crypto.Server = this.txtServer.Text;
crypto.User = this.txtUserId.Text;
crypto.Encrypt();
}
public void Decrypt()
{
crypto.Decrypt();
this.txtDatabase.Text = crypto.Database;
this.txtPassword.Text = crypto.Password;
this.txtProvider.Text = crypto.Provider;
this.txtServer.Text = crypto.Server;
this.txtUserId.Text = crypto.User;
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.txtProvider = new System.Windows.Forms.TextBox();
this.txtPassword = new System.Windows.Forms.TextBox();
this.txtUserId = new System.Windows.Forms.TextBox();
this.txtDatabase = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.txtServer = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(8, 140);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(53, 13);
this.label5.TabIndex = 23;
this.label5.Text = "Provider :";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(8, 108);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(60, 13);
this.label4.TabIndex = 22;
this.label4.Text = "Password :";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(8, 76);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(47, 13);
this.label3.TabIndex = 21;
this.label3.Text = "User Id :";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(8, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(59, 13);
this.label2.TabIndex = 20;
this.label2.Text = "Database :";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(8, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(44, 13);
this.label1.TabIndex = 19;
this.label1.Text = "Server :";
//
// txtProvider
//
this.txtProvider.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.txtProvider.Location = new System.Drawing.Point(80, 136);
this.txtProvider.Name = "txtProvider";
this.txtProvider.Size = new System.Drawing.Size(260, 20);
this.txtProvider.TabIndex = 18;
this.txtProvider.Text = "";
//
// txtPassword
//
this.txtPassword.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.txtPassword.Location = new System.Drawing.Point(80, 104);
this.txtPassword.Name = "txtPassword";
this.txtPassword.Size = new System.Drawing.Size(260, 20);
this.txtPassword.TabIndex = 17;
this.txtPassword.Text = "";
//
// txtUserId
//
this.txtUserId.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.txtUserId.Location = new System.Drawing.Point(80, 72);
this.txtUserId.Name = "txtUserId";
this.txtUserId.Size = new System.Drawing.Size(260, 20);
this.txtUserId.TabIndex = 16;
this.txtUserId.Text = "";
//
// txtDatabase
//
this.txtDatabase.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.txtDatabase.Location = new System.Drawing.Point(80, 44);
this.txtDatabase.Name = "txtDatabase";
this.txtDatabase.Size = new System.Drawing.Size(260, 20);
this.txtDatabase.TabIndex = 15;
this.txtDatabase.Text = "";
//
// button2
//
this.button2.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
this.button2.Location = new System.Drawing.Point(264, 164);
this.button2.Name = "button2";
this.button2.TabIndex = 14;
this.button2.Text = "Encrypt";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
this.button1.Location = new System.Drawing.Point(176, 164);
this.button1.Name = "button1";
this.button1.TabIndex = 13;
this.button1.Text = "Decrypt";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// txtServer
//
this.txtServer.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.txtServer.Location = new System.Drawing.Point(80, 12);
this.txtServer.Name = "txtServer";
this.txtServer.Size = new System.Drawing.Size(260, 20);
this.txtServer.TabIndex = 12;
this.txtServer.Text = "";
//
// AsymmetricEncryption
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(352, 198);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label5,
this.label4,
this.label3,
this.label2,
this.label1,
this.txtProvider,
this.txtPassword,
this.txtUserId,
this.txtDatabase,
this.button2,
this.button1,
this.txtServer});
this.Name = "AsymmetricEncryption";
this.Text = "AsymmetricEncryption";
this.Load += new System.EventHandler(this.AsymmetricEncryption_Load);
this.ResumeLayout(false);
}
#endregion
private void AsymmetricEncryption_Load(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
this.Decrypt();
}
private void button2_Click(object sender, System.EventArgs e)
{
this.Encrypt();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -