
6 changed files with 898 additions and 216 deletions
-
220XCoder/Tools/FrmSecurity.Designer.cs
-
64XCoder/Tools/FrmSecurity.cs
-
458XCoder/Tools/FrmSymmetric.Designer.cs
-
243XCoder/Tools/FrmSymmetric.cs
-
120XCoder/Tools/FrmSymmetric.resx
-
9XCoder/XCoder.csproj
@ -0,0 +1,458 @@ |
|||
namespace XCoder.Tools |
|||
{ |
|||
partial class FrmSymmetric |
|||
{ |
|||
/// <summary>
|
|||
/// Required designer variable.
|
|||
/// </summary>
|
|||
private System.ComponentModel.IContainer components = null; |
|||
|
|||
/// <summary>
|
|||
/// Clean up any resources being used.
|
|||
/// </summary>
|
|||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|||
protected override void Dispose(bool disposing) |
|||
{ |
|||
if (disposing && (components != null)) |
|||
{ |
|||
components.Dispose(); |
|||
} |
|||
base.Dispose(disposing); |
|||
} |
|||
|
|||
#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.gbFunc = new System.Windows.Forms.GroupBox(); |
|||
this.btnRC42 = new System.Windows.Forms.Button(); |
|||
this.btnRC4 = new System.Windows.Forms.Button(); |
|||
this.btnAES2 = new System.Windows.Forms.Button(); |
|||
this.btnAES = new System.Windows.Forms.Button(); |
|||
this.btnDES2 = new System.Windows.Forms.Button(); |
|||
this.btnDES = new System.Windows.Forms.Button(); |
|||
this.gbSource = new System.Windows.Forms.GroupBox(); |
|||
this.btnExchange = new System.Windows.Forms.Button(); |
|||
this.rbBase64 = new System.Windows.Forms.RadioButton(); |
|||
this.rbHex = new System.Windows.Forms.RadioButton(); |
|||
this.rbString = new System.Windows.Forms.RadioButton(); |
|||
this.rtSource = new System.Windows.Forms.RichTextBox(); |
|||
this.gbResult = new System.Windows.Forms.GroupBox(); |
|||
this.cbBase64 = new System.Windows.Forms.CheckBox(); |
|||
this.cbHex = new System.Windows.Forms.CheckBox(); |
|||
this.cbString = new System.Windows.Forms.CheckBox(); |
|||
this.rtResult = new System.Windows.Forms.RichTextBox(); |
|||
this.gbPass = new System.Windows.Forms.GroupBox(); |
|||
this.rbBase642 = new System.Windows.Forms.RadioButton(); |
|||
this.rbHex2 = new System.Windows.Forms.RadioButton(); |
|||
this.rbString2 = new System.Windows.Forms.RadioButton(); |
|||
this.rtPass = new System.Windows.Forms.RichTextBox(); |
|||
this.label1 = new System.Windows.Forms.Label(); |
|||
this.cmbCipher = new System.Windows.Forms.ComboBox(); |
|||
this.label2 = new System.Windows.Forms.Label(); |
|||
this.cmbPadding = new System.Windows.Forms.ComboBox(); |
|||
this.gbFunc.SuspendLayout(); |
|||
this.gbSource.SuspendLayout(); |
|||
this.gbResult.SuspendLayout(); |
|||
this.gbPass.SuspendLayout(); |
|||
this.SuspendLayout(); |
|||
//
|
|||
// gbFunc
|
|||
//
|
|||
this.gbFunc.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
|||
| System.Windows.Forms.AnchorStyles.Left))); |
|||
this.gbFunc.Controls.Add(this.cmbPadding); |
|||
this.gbFunc.Controls.Add(this.label2); |
|||
this.gbFunc.Controls.Add(this.cmbCipher); |
|||
this.gbFunc.Controls.Add(this.label1); |
|||
this.gbFunc.Controls.Add(this.btnRC42); |
|||
this.gbFunc.Controls.Add(this.btnRC4); |
|||
this.gbFunc.Controls.Add(this.btnAES2); |
|||
this.gbFunc.Controls.Add(this.btnAES); |
|||
this.gbFunc.Controls.Add(this.btnDES2); |
|||
this.gbFunc.Controls.Add(this.btnDES); |
|||
this.gbFunc.Location = new System.Drawing.Point(18, 18); |
|||
this.gbFunc.Margin = new System.Windows.Forms.Padding(4); |
|||
this.gbFunc.Name = "gbFunc"; |
|||
this.gbFunc.Padding = new System.Windows.Forms.Padding(4); |
|||
this.gbFunc.Size = new System.Drawing.Size(258, 908); |
|||
this.gbFunc.TabIndex = 0; |
|||
this.gbFunc.TabStop = false; |
|||
this.gbFunc.Text = "加密解密"; |
|||
//
|
|||
// btnRC42
|
|||
//
|
|||
this.btnRC42.Location = new System.Drawing.Point(130, 450); |
|||
this.btnRC42.Margin = new System.Windows.Forms.Padding(4); |
|||
this.btnRC42.Name = "btnRC42"; |
|||
this.btnRC42.Size = new System.Drawing.Size(112, 45); |
|||
this.btnRC42.TabIndex = 13; |
|||
this.btnRC42.Text = "RC4解密"; |
|||
this.btnRC42.UseVisualStyleBackColor = true; |
|||
this.btnRC42.Click += new System.EventHandler(this.btnRC42_Click); |
|||
//
|
|||
// btnRC4
|
|||
//
|
|||
this.btnRC4.Location = new System.Drawing.Point(9, 450); |
|||
this.btnRC4.Margin = new System.Windows.Forms.Padding(4); |
|||
this.btnRC4.Name = "btnRC4"; |
|||
this.btnRC4.Size = new System.Drawing.Size(112, 45); |
|||
this.btnRC4.TabIndex = 12; |
|||
this.btnRC4.Text = "RC4加密"; |
|||
this.btnRC4.UseVisualStyleBackColor = true; |
|||
this.btnRC4.Click += new System.EventHandler(this.btnRC4_Click); |
|||
//
|
|||
// btnAES2
|
|||
//
|
|||
this.btnAES2.Location = new System.Drawing.Point(130, 398); |
|||
this.btnAES2.Margin = new System.Windows.Forms.Padding(4); |
|||
this.btnAES2.Name = "btnAES2"; |
|||
this.btnAES2.Size = new System.Drawing.Size(112, 45); |
|||
this.btnAES2.TabIndex = 11; |
|||
this.btnAES2.Text = "AES解密"; |
|||
this.btnAES2.UseVisualStyleBackColor = true; |
|||
this.btnAES2.Click += new System.EventHandler(this.btnAES2_Click); |
|||
//
|
|||
// btnAES
|
|||
//
|
|||
this.btnAES.Location = new System.Drawing.Point(9, 398); |
|||
this.btnAES.Margin = new System.Windows.Forms.Padding(4); |
|||
this.btnAES.Name = "btnAES"; |
|||
this.btnAES.Size = new System.Drawing.Size(112, 45); |
|||
this.btnAES.TabIndex = 10; |
|||
this.btnAES.Text = "AES加密"; |
|||
this.btnAES.UseVisualStyleBackColor = true; |
|||
this.btnAES.Click += new System.EventHandler(this.btnAES_Click); |
|||
//
|
|||
// btnDES2
|
|||
//
|
|||
this.btnDES2.Location = new System.Drawing.Point(130, 345); |
|||
this.btnDES2.Margin = new System.Windows.Forms.Padding(4); |
|||
this.btnDES2.Name = "btnDES2"; |
|||
this.btnDES2.Size = new System.Drawing.Size(112, 45); |
|||
this.btnDES2.TabIndex = 9; |
|||
this.btnDES2.Text = "DES解密"; |
|||
this.btnDES2.UseVisualStyleBackColor = true; |
|||
this.btnDES2.Click += new System.EventHandler(this.btnDES2_Click); |
|||
//
|
|||
// btnDES
|
|||
//
|
|||
this.btnDES.Location = new System.Drawing.Point(9, 345); |
|||
this.btnDES.Margin = new System.Windows.Forms.Padding(4); |
|||
this.btnDES.Name = "btnDES"; |
|||
this.btnDES.Size = new System.Drawing.Size(112, 45); |
|||
this.btnDES.TabIndex = 8; |
|||
this.btnDES.Text = "DES加密"; |
|||
this.btnDES.UseVisualStyleBackColor = true; |
|||
this.btnDES.Click += new System.EventHandler(this.btnDES_Click); |
|||
//
|
|||
// gbSource
|
|||
//
|
|||
this.gbSource.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
|||
| System.Windows.Forms.AnchorStyles.Right))); |
|||
this.gbSource.Controls.Add(this.btnExchange); |
|||
this.gbSource.Controls.Add(this.rbBase64); |
|||
this.gbSource.Controls.Add(this.rbHex); |
|||
this.gbSource.Controls.Add(this.rbString); |
|||
this.gbSource.Controls.Add(this.rtSource); |
|||
this.gbSource.Location = new System.Drawing.Point(285, 18); |
|||
this.gbSource.Margin = new System.Windows.Forms.Padding(4); |
|||
this.gbSource.Name = "gbSource"; |
|||
this.gbSource.Padding = new System.Windows.Forms.Padding(4); |
|||
this.gbSource.Size = new System.Drawing.Size(1006, 375); |
|||
this.gbSource.TabIndex = 3; |
|||
this.gbSource.TabStop = false; |
|||
this.gbSource.Text = "原文"; |
|||
//
|
|||
// btnExchange
|
|||
//
|
|||
this.btnExchange.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); |
|||
this.btnExchange.Location = new System.Drawing.Point(894, 13); |
|||
this.btnExchange.Margin = new System.Windows.Forms.Padding(4); |
|||
this.btnExchange.Name = "btnExchange"; |
|||
this.btnExchange.Size = new System.Drawing.Size(104, 51); |
|||
this.btnExchange.TabIndex = 6; |
|||
this.btnExchange.Text = "上下互换"; |
|||
this.btnExchange.UseVisualStyleBackColor = true; |
|||
this.btnExchange.Click += new System.EventHandler(this.btnExchange_Click); |
|||
//
|
|||
// rbBase64
|
|||
//
|
|||
this.rbBase64.AutoSize = true; |
|||
this.rbBase64.Location = new System.Drawing.Point(299, 28); |
|||
this.rbBase64.Margin = new System.Windows.Forms.Padding(2); |
|||
this.rbBase64.Name = "rbBase64"; |
|||
this.rbBase64.Size = new System.Drawing.Size(123, 22); |
|||
this.rbBase64.TabIndex = 5; |
|||
this.rbBase64.Text = "BASE64编码"; |
|||
this.rbBase64.UseVisualStyleBackColor = true; |
|||
//
|
|||
// rbHex
|
|||
//
|
|||
this.rbHex.AutoSize = true; |
|||
this.rbHex.Location = new System.Drawing.Point(154, 28); |
|||
this.rbHex.Margin = new System.Windows.Forms.Padding(2); |
|||
this.rbHex.Name = "rbHex"; |
|||
this.rbHex.Size = new System.Drawing.Size(96, 22); |
|||
this.rbHex.TabIndex = 4; |
|||
this.rbHex.Text = "HEX编码"; |
|||
this.rbHex.UseVisualStyleBackColor = true; |
|||
//
|
|||
// rbString
|
|||
//
|
|||
this.rbString.AutoSize = true; |
|||
this.rbString.Checked = true; |
|||
this.rbString.Location = new System.Drawing.Point(19, 28); |
|||
this.rbString.Margin = new System.Windows.Forms.Padding(2); |
|||
this.rbString.Name = "rbString"; |
|||
this.rbString.Size = new System.Drawing.Size(87, 22); |
|||
this.rbString.TabIndex = 3; |
|||
this.rbString.TabStop = true; |
|||
this.rbString.Text = "字符串"; |
|||
this.rbString.UseVisualStyleBackColor = true; |
|||
//
|
|||
// rtSource
|
|||
//
|
|||
this.rtSource.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
|||
| System.Windows.Forms.AnchorStyles.Left) |
|||
| System.Windows.Forms.AnchorStyles.Right))); |
|||
this.rtSource.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
|||
this.rtSource.Location = new System.Drawing.Point(4, 65); |
|||
this.rtSource.Margin = new System.Windows.Forms.Padding(4); |
|||
this.rtSource.Name = "rtSource"; |
|||
this.rtSource.Size = new System.Drawing.Size(998, 306); |
|||
this.rtSource.TabIndex = 2; |
|||
this.rtSource.Text = "学无先后达者为师"; |
|||
this.rtSource.TextChanged += new System.EventHandler(this.rtSource_TextChanged); |
|||
//
|
|||
// gbResult
|
|||
//
|
|||
this.gbResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
|||
| System.Windows.Forms.AnchorStyles.Left) |
|||
| System.Windows.Forms.AnchorStyles.Right))); |
|||
this.gbResult.Controls.Add(this.cbBase64); |
|||
this.gbResult.Controls.Add(this.cbHex); |
|||
this.gbResult.Controls.Add(this.cbString); |
|||
this.gbResult.Controls.Add(this.rtResult); |
|||
this.gbResult.Location = new System.Drawing.Point(285, 552); |
|||
this.gbResult.Margin = new System.Windows.Forms.Padding(4); |
|||
this.gbResult.Name = "gbResult"; |
|||
this.gbResult.Padding = new System.Windows.Forms.Padding(4); |
|||
this.gbResult.Size = new System.Drawing.Size(1006, 375); |
|||
this.gbResult.TabIndex = 4; |
|||
this.gbResult.TabStop = false; |
|||
this.gbResult.Text = "结果"; |
|||
//
|
|||
// cbBase64
|
|||
//
|
|||
this.cbBase64.AutoSize = true; |
|||
this.cbBase64.Checked = true; |
|||
this.cbBase64.CheckState = System.Windows.Forms.CheckState.Checked; |
|||
this.cbBase64.Location = new System.Drawing.Point(299, 28); |
|||
this.cbBase64.Margin = new System.Windows.Forms.Padding(2); |
|||
this.cbBase64.Name = "cbBase64"; |
|||
this.cbBase64.Size = new System.Drawing.Size(124, 22); |
|||
this.cbBase64.TabIndex = 8; |
|||
this.cbBase64.Text = "BASE64编码"; |
|||
this.cbBase64.UseVisualStyleBackColor = true; |
|||
//
|
|||
// cbHex
|
|||
//
|
|||
this.cbHex.AutoSize = true; |
|||
this.cbHex.Checked = true; |
|||
this.cbHex.CheckState = System.Windows.Forms.CheckState.Checked; |
|||
this.cbHex.Location = new System.Drawing.Point(154, 28); |
|||
this.cbHex.Margin = new System.Windows.Forms.Padding(2); |
|||
this.cbHex.Name = "cbHex"; |
|||
this.cbHex.Size = new System.Drawing.Size(97, 22); |
|||
this.cbHex.TabIndex = 7; |
|||
this.cbHex.Text = "HEX编码"; |
|||
this.cbHex.UseVisualStyleBackColor = true; |
|||
//
|
|||
// cbString
|
|||
//
|
|||
this.cbString.AutoSize = true; |
|||
this.cbString.Checked = true; |
|||
this.cbString.CheckState = System.Windows.Forms.CheckState.Checked; |
|||
this.cbString.Location = new System.Drawing.Point(19, 28); |
|||
this.cbString.Margin = new System.Windows.Forms.Padding(2); |
|||
this.cbString.Name = "cbString"; |
|||
this.cbString.Size = new System.Drawing.Size(88, 22); |
|||
this.cbString.TabIndex = 6; |
|||
this.cbString.Text = "字符串"; |
|||
this.cbString.UseVisualStyleBackColor = true; |
|||
//
|
|||
// rtResult
|
|||
//
|
|||
this.rtResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
|||
| System.Windows.Forms.AnchorStyles.Left) |
|||
| System.Windows.Forms.AnchorStyles.Right))); |
|||
this.rtResult.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
|||
this.rtResult.Location = new System.Drawing.Point(4, 57); |
|||
this.rtResult.Margin = new System.Windows.Forms.Padding(4); |
|||
this.rtResult.Name = "rtResult"; |
|||
this.rtResult.Size = new System.Drawing.Size(998, 314); |
|||
this.rtResult.TabIndex = 2; |
|||
this.rtResult.Text = ""; |
|||
//
|
|||
// gbPass
|
|||
//
|
|||
this.gbPass.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
|||
| System.Windows.Forms.AnchorStyles.Right))); |
|||
this.gbPass.Controls.Add(this.rbBase642); |
|||
this.gbPass.Controls.Add(this.rbHex2); |
|||
this.gbPass.Controls.Add(this.rbString2); |
|||
this.gbPass.Controls.Add(this.rtPass); |
|||
this.gbPass.Location = new System.Drawing.Point(285, 398); |
|||
this.gbPass.Margin = new System.Windows.Forms.Padding(4); |
|||
this.gbPass.Name = "gbPass"; |
|||
this.gbPass.Padding = new System.Windows.Forms.Padding(4); |
|||
this.gbPass.Size = new System.Drawing.Size(1006, 150); |
|||
this.gbPass.TabIndex = 5; |
|||
this.gbPass.TabStop = false; |
|||
this.gbPass.Text = "密码"; |
|||
//
|
|||
// rbBase642
|
|||
//
|
|||
this.rbBase642.AutoSize = true; |
|||
this.rbBase642.Location = new System.Drawing.Point(299, 30); |
|||
this.rbBase642.Margin = new System.Windows.Forms.Padding(2); |
|||
this.rbBase642.Name = "rbBase642"; |
|||
this.rbBase642.Size = new System.Drawing.Size(123, 22); |
|||
this.rbBase642.TabIndex = 8; |
|||
this.rbBase642.Text = "BASE64编码"; |
|||
this.rbBase642.UseVisualStyleBackColor = true; |
|||
//
|
|||
// rbHex2
|
|||
//
|
|||
this.rbHex2.AutoSize = true; |
|||
this.rbHex2.Location = new System.Drawing.Point(155, 30); |
|||
this.rbHex2.Margin = new System.Windows.Forms.Padding(2); |
|||
this.rbHex2.Name = "rbHex2"; |
|||
this.rbHex2.Size = new System.Drawing.Size(96, 22); |
|||
this.rbHex2.TabIndex = 7; |
|||
this.rbHex2.Text = "HEX编码"; |
|||
this.rbHex2.UseVisualStyleBackColor = true; |
|||
//
|
|||
// rbString2
|
|||
//
|
|||
this.rbString2.AutoSize = true; |
|||
this.rbString2.Checked = true; |
|||
this.rbString2.Location = new System.Drawing.Point(19, 30); |
|||
this.rbString2.Margin = new System.Windows.Forms.Padding(2); |
|||
this.rbString2.Name = "rbString2"; |
|||
this.rbString2.Size = new System.Drawing.Size(87, 22); |
|||
this.rbString2.TabIndex = 6; |
|||
this.rbString2.TabStop = true; |
|||
this.rbString2.Text = "字符串"; |
|||
this.rbString2.UseVisualStyleBackColor = true; |
|||
//
|
|||
// rtPass
|
|||
//
|
|||
this.rtPass.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
|||
| System.Windows.Forms.AnchorStyles.Left) |
|||
| System.Windows.Forms.AnchorStyles.Right))); |
|||
this.rtPass.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
|||
this.rtPass.Location = new System.Drawing.Point(4, 64); |
|||
this.rtPass.Margin = new System.Windows.Forms.Padding(4); |
|||
this.rtPass.Name = "rtPass"; |
|||
this.rtPass.Size = new System.Drawing.Size(998, 82); |
|||
this.rtPass.TabIndex = 2; |
|||
this.rtPass.Text = "NewLife"; |
|||
//
|
|||
// label1
|
|||
//
|
|||
this.label1.AutoSize = true; |
|||
this.label1.Location = new System.Drawing.Point(7, 46); |
|||
this.label1.Name = "label1"; |
|||
this.label1.Size = new System.Drawing.Size(116, 18); |
|||
this.label1.TabIndex = 14; |
|||
this.label1.Text = "块密码模式:"; |
|||
//
|
|||
// cmbCipher
|
|||
//
|
|||
this.cmbCipher.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; |
|||
this.cmbCipher.FormattingEnabled = true; |
|||
this.cmbCipher.Location = new System.Drawing.Point(129, 42); |
|||
this.cmbCipher.Name = "cmbCipher"; |
|||
this.cmbCipher.Size = new System.Drawing.Size(121, 26); |
|||
this.cmbCipher.TabIndex = 15; |
|||
//
|
|||
// label2
|
|||
//
|
|||
this.label2.AutoSize = true; |
|||
this.label2.Location = new System.Drawing.Point(25, 95); |
|||
this.label2.Name = "label2"; |
|||
this.label2.Size = new System.Drawing.Size(98, 18); |
|||
this.label2.TabIndex = 16; |
|||
this.label2.Text = "填充类型:"; |
|||
//
|
|||
// cmbPadding
|
|||
//
|
|||
this.cmbPadding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; |
|||
this.cmbPadding.FormattingEnabled = true; |
|||
this.cmbPadding.Location = new System.Drawing.Point(129, 91); |
|||
this.cmbPadding.Name = "cmbPadding"; |
|||
this.cmbPadding.Size = new System.Drawing.Size(121, 26); |
|||
this.cmbPadding.TabIndex = 17; |
|||
//
|
|||
// FrmSymmetric
|
|||
//
|
|||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); |
|||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
|||
this.ClientSize = new System.Drawing.Size(1304, 944); |
|||
this.Controls.Add(this.gbPass); |
|||
this.Controls.Add(this.gbResult); |
|||
this.Controls.Add(this.gbSource); |
|||
this.Controls.Add(this.gbFunc); |
|||
this.Margin = new System.Windows.Forms.Padding(4); |
|||
this.Name = "FrmSymmetric"; |
|||
this.Text = "加密解密"; |
|||
this.Load += new System.EventHandler(this.FrmSecurity_Load); |
|||
this.gbFunc.ResumeLayout(false); |
|||
this.gbFunc.PerformLayout(); |
|||
this.gbSource.ResumeLayout(false); |
|||
this.gbSource.PerformLayout(); |
|||
this.gbResult.ResumeLayout(false); |
|||
this.gbResult.PerformLayout(); |
|||
this.gbPass.ResumeLayout(false); |
|||
this.gbPass.PerformLayout(); |
|||
this.ResumeLayout(false); |
|||
|
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
private System.Windows.Forms.GroupBox gbFunc; |
|||
private System.Windows.Forms.GroupBox gbSource; |
|||
private System.Windows.Forms.RichTextBox rtSource; |
|||
private System.Windows.Forms.GroupBox gbResult; |
|||
private System.Windows.Forms.RichTextBox rtResult; |
|||
private System.Windows.Forms.Button btnRC42; |
|||
private System.Windows.Forms.Button btnRC4; |
|||
private System.Windows.Forms.Button btnAES2; |
|||
private System.Windows.Forms.Button btnAES; |
|||
private System.Windows.Forms.Button btnDES2; |
|||
private System.Windows.Forms.Button btnDES; |
|||
private System.Windows.Forms.GroupBox gbPass; |
|||
private System.Windows.Forms.RichTextBox rtPass; |
|||
private System.Windows.Forms.Button btnExchange; |
|||
private System.Windows.Forms.CheckBox cbBase64; |
|||
private System.Windows.Forms.CheckBox cbHex; |
|||
private System.Windows.Forms.CheckBox cbString; |
|||
private System.Windows.Forms.RadioButton rbBase64; |
|||
private System.Windows.Forms.RadioButton rbHex; |
|||
private System.Windows.Forms.RadioButton rbString; |
|||
private System.Windows.Forms.RadioButton rbBase642; |
|||
private System.Windows.Forms.RadioButton rbHex2; |
|||
private System.Windows.Forms.RadioButton rbString2; |
|||
private System.Windows.Forms.ComboBox cmbPadding; |
|||
private System.Windows.Forms.Label label2; |
|||
private System.Windows.Forms.ComboBox cmbCipher; |
|||
private System.Windows.Forms.Label label1; |
|||
} |
|||
} |
@ -0,0 +1,243 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel; |
|||
using System.Security.Cryptography; |
|||
using System.Text; |
|||
using System.Windows.Forms; |
|||
using NewLife; |
|||
using XCoder.Common; |
|||
|
|||
namespace XCoder.Tools |
|||
{ |
|||
[Category("安全工具")] |
|||
[DisplayName("对称加密")] |
|||
public partial class FrmSymmetric : Form, IXForm |
|||
{ |
|||
private ControlConfig _config; |
|||
|
|||
#region 窗体初始化
|
|||
public FrmSymmetric() |
|||
{ |
|||
InitializeComponent(); |
|||
|
|||
// 动态调节宽度高度,兼容高DPI
|
|||
this.FixDpi(); |
|||
} |
|||
|
|||
private void FrmSecurity_Load(Object sender, EventArgs e) |
|||
{ |
|||
cmbCipher.DataSource = Enum.GetValues(typeof(CipherMode)); |
|||
cmbPadding.DataSource = Enum.GetValues(typeof(PaddingMode)); |
|||
cmbCipher.SelectedItem = CipherMode.CBC; |
|||
cmbPadding.SelectedItem = PaddingMode.PKCS7; |
|||
|
|||
_config = new ControlConfig { Control = this, FileName = "Symmetric.json" }; |
|||
_config.Load(); |
|||
} |
|||
#endregion
|
|||
|
|||
#region 辅助
|
|||
/// <summary>从字符串中获取字节数组</summary>
|
|||
/// <param name="str"></param>
|
|||
/// <returns></returns>
|
|||
private Byte[] GetBytes(String str) |
|||
{ |
|||
if (str.IsNullOrEmpty()) return new Byte[0]; |
|||
|
|||
try |
|||
{ |
|||
if (str.Contains("-")) return str.ToHex(); |
|||
} |
|||
catch { } |
|||
|
|||
try |
|||
{ |
|||
return str.ToBase64(); |
|||
} |
|||
catch { } |
|||
|
|||
return str.GetBytes(); |
|||
} |
|||
|
|||
/// <summary>从原文中获取字节数组</summary>
|
|||
/// <returns></returns>
|
|||
private Byte[] GetSource() |
|||
{ |
|||
var v = rtSource.Text; |
|||
|
|||
if (rbString.Checked) return v.GetBytes(); |
|||
if (rbHex.Checked) return v.ToHex(); |
|||
if (rbBase64.Checked) return v.ToBase64(); |
|||
|
|||
return null; |
|||
} |
|||
|
|||
private void rtSource_TextChanged(Object sender, EventArgs e) |
|||
{ |
|||
var v = rtSource.Text; |
|||
if (v.IsNullOrEmpty()) return; |
|||
|
|||
// 单字节
|
|||
var enc = Encoding.UTF8; |
|||
if (enc.GetByteCount(v) != v.Length) |
|||
{ |
|||
rbHex.Enabled = false; |
|||
rbBase64.Enabled = false; |
|||
return; |
|||
} |
|||
|
|||
try |
|||
{ |
|||
rbHex.Enabled = v.ToHex().Length > 0; |
|||
} |
|||
catch |
|||
{ |
|||
rbHex.Enabled = false; |
|||
} |
|||
|
|||
try |
|||
{ |
|||
rbBase64.Enabled = v.ToBase64().Length > 0; |
|||
} |
|||
catch |
|||
{ |
|||
rbBase64.Enabled = false; |
|||
} |
|||
} |
|||
|
|||
private Byte[] GetPass() |
|||
{ |
|||
var v = rtPass.Text; |
|||
|
|||
if (rbString2.Checked) return v.GetBytes(); |
|||
if (rbHex2.Checked) return v.ToHex(); |
|||
if (rbBase642.Checked) return v.ToBase64(); |
|||
|
|||
return null; |
|||
} |
|||
|
|||
private void SetResult(params String[] rs) |
|||
{ |
|||
var sb = new StringBuilder(); |
|||
foreach (var item in rs) |
|||
{ |
|||
if (sb.Length > 0) sb.AppendLine(); |
|||
sb.Append(item); |
|||
} |
|||
rtResult.Text = sb.ToString(); |
|||
|
|||
_config.Save(); |
|||
} |
|||
|
|||
private void SetResult(Byte[] data) |
|||
{ |
|||
//SetResult("/*HEX编码、Base64编码、Url改进Base64编码*/", data.ToHex("-"), data.ToBase64(), data.ToUrlBase64());
|
|||
|
|||
var list = new List<String>(); |
|||
if (cbString.Checked) list.Add(data.ToStr()); |
|||
if (cbHex.Checked) |
|||
{ |
|||
list.Add(data.ToHex().ToUpper()); |
|||
list.Add(data.ToHex().ToLower()); |
|||
list.Add(data.ToHex("-")); |
|||
list.Add(data.ToHex(" ")); |
|||
} |
|||
if (cbBase64.Checked) |
|||
{ |
|||
list.Add(data.ToBase64()); |
|||
list.Add(data.ToUrlBase64()); |
|||
} |
|||
|
|||
SetResult(list.ToArray()); |
|||
} |
|||
#endregion
|
|||
|
|||
#region 功能
|
|||
private void btnExchange_Click(Object sender, EventArgs e) |
|||
{ |
|||
var v = rtSource.Text; |
|||
var v2 = rtResult.Text; |
|||
// 结果区只要第一行
|
|||
if (!v2.IsNullOrEmpty()) |
|||
{ |
|||
var ss = v2.Split("\n"); |
|||
var n = 0; |
|||
if (ss.Length > n + 1 && ss[n].StartsWith("/*") && ss[n].EndsWith("*/")) n++; |
|||
v2 = ss[n]; |
|||
} |
|||
rtSource.Text = v2; |
|||
rtResult.Text = v; |
|||
} |
|||
|
|||
private void btnDES_Click(Object sender, EventArgs e) |
|||
{ |
|||
var buf = GetSource(); |
|||
var pass = GetPass(); |
|||
|
|||
var mode = (CipherMode)Enum.Parse(typeof(CipherMode), cmbCipher.SelectedItem + ""); |
|||
var padding = (PaddingMode)Enum.Parse(typeof(PaddingMode), cmbPadding.SelectedItem + ""); |
|||
var des = new DESCryptoServiceProvider(); |
|||
buf = des.Encrypt(buf, pass, mode, padding); |
|||
|
|||
SetResult(buf); |
|||
} |
|||
|
|||
private void btnDES2_Click(Object sender, EventArgs e) |
|||
{ |
|||
var buf = GetSource(); |
|||
var pass = GetPass(); |
|||
|
|||
var mode = (CipherMode)Enum.Parse(typeof(CipherMode), cmbCipher.SelectedItem + ""); |
|||
var padding = (PaddingMode)Enum.Parse(typeof(PaddingMode), cmbPadding.SelectedItem + ""); |
|||
var des = new DESCryptoServiceProvider(); |
|||
buf = des.Decrypt(buf, pass, mode, padding); |
|||
|
|||
SetResult(buf); |
|||
} |
|||
|
|||
private void btnAES_Click(Object sender, EventArgs e) |
|||
{ |
|||
var buf = GetSource(); |
|||
var pass = GetPass(); |
|||
|
|||
var mode = (CipherMode)Enum.Parse(typeof(CipherMode), cmbCipher.SelectedItem + ""); |
|||
var padding = (PaddingMode)Enum.Parse(typeof(PaddingMode), cmbPadding.SelectedItem + ""); |
|||
var aes = new AesCryptoServiceProvider(); |
|||
buf = aes.Encrypt(buf, pass, mode, padding); |
|||
|
|||
SetResult(buf); |
|||
} |
|||
|
|||
private void btnAES2_Click(Object sender, EventArgs e) |
|||
{ |
|||
var buf = GetSource(); |
|||
var pass = GetPass(); |
|||
|
|||
var mode = (CipherMode)Enum.Parse(typeof(CipherMode), cmbCipher.SelectedItem + ""); |
|||
var padding = (PaddingMode)Enum.Parse(typeof(PaddingMode), cmbPadding.SelectedItem + ""); |
|||
var aes = new AesCryptoServiceProvider(); |
|||
buf = aes.Decrypt(buf, pass, mode, padding); |
|||
|
|||
SetResult(buf); |
|||
} |
|||
|
|||
private void btnRC4_Click(Object sender, EventArgs e) |
|||
{ |
|||
var buf = GetSource(); |
|||
var pass = GetPass(); |
|||
buf = buf.RC4(pass); |
|||
|
|||
SetResult(buf); |
|||
} |
|||
|
|||
private void btnRC42_Click(Object sender, EventArgs e) |
|||
{ |
|||
var buf = GetSource(); |
|||
var pass = GetPass(); |
|||
buf = buf.RC4(pass); |
|||
|
|||
SetResult(buf); |
|||
} |
|||
#endregion
|
|||
} |
|||
} |
@ -0,0 +1,120 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<root> |
|||
<!-- |
|||
Microsoft ResX Schema |
|||
|
|||
Version 2.0 |
|||
|
|||
The primary goals of this format is to allow a simple XML format |
|||
that is mostly human readable. The generation and parsing of the |
|||
various data types are done through the TypeConverter classes |
|||
associated with the data types. |
|||
|
|||
Example: |
|||
|
|||
... ado.net/XML headers & schema ... |
|||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
|||
<resheader name="version">2.0</resheader> |
|||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
|||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
|||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
|||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
|||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
|||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
|||
</data> |
|||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
|||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
|||
<comment>This is a comment</comment> |
|||
</data> |
|||
|
|||
There are any number of "resheader" rows that contain simple |
|||
name/value pairs. |
|||
|
|||
Each data row contains a name, and value. The row also contains a |
|||
type or mimetype. Type corresponds to a .NET class that support |
|||
text/value conversion through the TypeConverter architecture. |
|||
Classes that don't support this are serialized and stored with the |
|||
mimetype set. |
|||
|
|||
The mimetype is used for serialized objects, and tells the |
|||
ResXResourceReader how to depersist the object. This is currently not |
|||
extensible. For a given mimetype the value must be set accordingly: |
|||
|
|||
Note - application/x-microsoft.net.object.binary.base64 is the format |
|||
that the ResXResourceWriter will generate, however the reader can |
|||
read any of the formats listed below. |
|||
|
|||
mimetype: application/x-microsoft.net.object.binary.base64 |
|||
value : The object must be serialized with |
|||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
|||
: and then encoded with base64 encoding. |
|||
|
|||
mimetype: application/x-microsoft.net.object.soap.base64 |
|||
value : The object must be serialized with |
|||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
|||
: and then encoded with base64 encoding. |
|||
|
|||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
|||
value : The object must be serialized into a byte array |
|||
: using a System.ComponentModel.TypeConverter |
|||
: and then encoded with base64 encoding. |
|||
--> |
|||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
|||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
|||
<xsd:element name="root" msdata:IsDataSet="true"> |
|||
<xsd:complexType> |
|||
<xsd:choice maxOccurs="unbounded"> |
|||
<xsd:element name="metadata"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" use="required" type="xsd:string" /> |
|||
<xsd:attribute name="type" type="xsd:string" /> |
|||
<xsd:attribute name="mimetype" type="xsd:string" /> |
|||
<xsd:attribute ref="xml:space" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="assembly"> |
|||
<xsd:complexType> |
|||
<xsd:attribute name="alias" type="xsd:string" /> |
|||
<xsd:attribute name="name" type="xsd:string" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="data"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
|||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
|||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
|||
<xsd:attribute ref="xml:space" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="resheader"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:choice> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:schema> |
|||
<resheader name="resmimetype"> |
|||
<value>text/microsoft-resx</value> |
|||
</resheader> |
|||
<resheader name="version"> |
|||
<value>2.0</value> |
|||
</resheader> |
|||
<resheader name="reader"> |
|||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|||
</resheader> |
|||
<resheader name="writer"> |
|||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|||
</resheader> |
|||
</root> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue