Intermediary transaction SEO diagnosis Taobao guest Cloud host technology Hall
[Original] Practical password encryption tool (C # code)
Running platform: Microsoft. NET Framework v1.1
Development platform: Microsoft Visual Studio. NET 2003
Using System;
Using System.Drawing;
Using System.Collections;
Using System.ComponentModel;
Using System.Windows.Forms;
Using System.Data;
Using System.Security.Cryptography;
Using System.Web.Security;
Namespace Hashpassword
{
///
Summary description of the Form1.
///
public class Form1:System.Windows.Forms.Form
{
Private System.Windows.Forms.Label Label1;
Private System.Windows.Forms.Label Label2;
Private System.Windows.Forms.TextBox Text_source;
Private System.Windows.Forms.Button button1;
Private System.Windows.Forms.Button button2;
Private System.Windows.Forms.TextBox Text_result;
Private System.Windows.Forms.RadioButton Radio32;
Private System.Windows.Forms.RadioButton radio16;
Private System.Windows.Forms.RadioButton radio40;
Private System.Windows.Forms.RadioButton Radio1;
///
Required designer variable.
///
Private System.ComponentModel.Container rs = null;
Public Form1 ()
{
//
Required for Windows Forms Designer support
//
InitializeComponent ();
//
TODO: Add any constructor code after InitializeComponent call
//
}
///
Clean up all resources in use.
///
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (Rs!= null)
{
Rs. Dispose ();
}
}
Base. Dispose (disposing);
}
Code generated #region the Windows forms Designer
///
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
///
private void InitializeComponent ()
{
This.label1 = new System.Windows.Forms.Label ();
This.label2 = new System.Windows.Forms.Label ();
This. Text_result = new System.Windows.Forms.TextBox ();
This. Text_source = new System.Windows.Forms.TextBox ();
This.button1 = new System.Windows.Forms.Button ();
This.button2 = new System.Windows.Forms.Button ();
This.radio32 = new System.Windows.Forms.RadioButton ();
this.radio16 = new System.Windows.Forms.RadioButton ();
This.radio40 = new System.Windows.Forms.RadioButton ();
This.radio1 = new System.Windows.Forms.RadioButton ();
This. SuspendLayout ();
//
Label1
//
This.label1.Location = new System.Drawing.Point (32, 24);
This.label1.Name = "Label1";
This.label1.Size = new System.Drawing.Size (96, 16);
This.label1.TabIndex = 1;
This.label1.Text = "Pre-encrypted string:";
//
Label2
//
This.label2.Location = new System.Drawing.Point (32, 88);
This.label2.Name = "Label2";
This.label2.Size = new System.Drawing.Size (96, 16);
This.label2.TabIndex = 2;
This.label2.Text = "Encrypted string:";
//
Text_result
//
This. Text_result.backcolor = System.Drawing.SystemColors.HighlightText;
This. Text_result.location = new System.Drawing.Point (120, 80);
This. Text_result.name = "Text_result";
This. Text_result.readonly = true;
This. Text_result.size = new System.Drawing.Size (248, 21);
This. Text_result.tabindex = 3;
This. Text_result.text = "";
//
Text_source
//
This. Text_source.location = new System.Drawing.Point (120, 16);
This. Text_source.name = "Text_source";
This. Text_source.size = new System.Drawing.Size (248, 21);
This. Text_source.tabindex = 2;
This. Text_source.text = "";
This. Text_source.textchanged + = new System.EventHandler (this. text_source_textchanged);
//
Button1
//
This.button1.Location = new System.Drawing.Point (120, 112);
This.button1.Name = "Button1";
This.button1.TabIndex = 5;
This.button1.Text = "Encrypt";
This.button1.Click + = new System.EventHandler (This.button1_click);
//
Button2
//
This.button2.Location = new System.Drawing.Point (240, 112);
This.button2.Name = "Button2";
This.button2.TabIndex = 6;
This.button2.Text = "Exit";
This.button2.Click + = new System.EventHandler (This.button2_click);
//
Radio32
//
This.radio32.Checked = true;
This.radio32.Location = new System.Drawing.Point (72, 48);
This.radio32.Name = "Radio32";
This.radio32.Size = new System.Drawing.Size (72, 24);
This.radio32.TabIndex = 7;
This.radio32.TabStop = true;
This.radio32.Text = "md5_32 bit";
This.radio32.CheckedChanged + = new System.EventHandler (this.radio32_checkedchanged);
//
Radio16
//
This.radio16.Location = new System.Drawing.Point (144, 48);
This.radio16.Name = "Radio16";
This.radio16.Size = new System.Drawing.Size (72, 24);
This.radio16.TabIndex = 8;
This.radio16.Text = "Md5_16 bit";
This.radio16.CheckedChanged + = new System.EventHandler (this.radio16_checkedchanged);
//
Radio40
//
This.radio40.Location = new System.Drawing.Point (216, 48);
This.radio40.Name = "Radio40";
This.radio40.Size = new System.Drawing.Size (72, 24);
This.radio40.TabIndex = 9;
This.radio40.Text = "SHA1 Encryption";
This.radio40.CheckedChanged + = new System.EventHandler (this.radio40_checkedchanged);
//
Radio1
//
This.radio1.Location = new System.Drawing.Point (296, 48);
This.radio1.Name = "Radio1";
This.radio1.TabIndex = 10;
This.radio1.Text = "unique identity encryption";
This.radio1.CheckedChanged + = new System.EventHandler (this.radio1_checkedchanged);
//
Form1
//
This. AutoScaleBaseSize = new System.Drawing.Size (6, 14);
This. ClientSize = new System.Drawing.Size (416, 149);
This. Controls.Add (THIS.RADIO1);
This. Controls.Add (THIS.RADIO40);
This. Controls.Add (THIS.RADIO16);
This. Controls.Add (THIS.RADIO32);
This. Controls.Add (This.button2);
This. Controls.Add (This.button1);
This. Controls.Add (this. Text_source);
This. Controls.Add (this. Text_result);
This. Controls.Add (THIS.LABEL2);
This. Controls.Add (THIS.LABEL1);
This. MaximizeBox = false;
This. Name = "Form1";
This. StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
This. Text = "Password encryption tool-Velon qq:7421021";
This. ResumeLayout (FALSE);
}
#endregion
///
The main entry point for the application.
///
[STAThread]
static void Main ()
{
Application.Run (New Form1 ());
}
private void Button2_Click (object sender, System.EventArgs e)
{
Application.exit ();
}
private void Button1_Click (object sender, System.EventArgs e)
{
Getcheckchanged ();
}
private string Gethashpassword_md5_32 (String sourcetext)
{
Return FormsAuthentication.HashPasswordForStoringInConfigFile (SourceText, "MD5"). ToLower ();
}
private string Gethashpassword_md5_16 (String sourcetext)
{
Return FormsAuthentication.HashPasswordForStoringInConfigFile (SourceText, "MD5"). ToLower (). Substring (9,0x10);
}
private string Gethashpassword_sha1_40 (String sourcetext)
{
Return FormsAuthentication.HashPasswordForStoringInConfigFile (SourceText, "SHA1"). ToLower ();
}
Private Guid Getstringhash (string sourcetext)
{
BYTE] bytes = System.Text.Encoding.Unicode.GetBytes (sourcetext);
MD5 MD5 = new MD5CryptoServiceProvider ();
BYTE] hashed = Md5.computehash (bytes);
GUID id = new GUID (hashed);
MD5. Clear ();
return ID;
}
private void Radio16_checkedchanged (object sender, System.EventArgs e)
{
Text_result.text = Gethashpassword_md5_16 (Text_source.text);
}
private void Radio40_checkedchanged (object sender, System.EventArgs e)
{
Text_result.text = gethashpassword_sha1_40 (Text_source.text);
}
private void Radio1_checkedchanged (object sender, System.EventArgs e)
{
Text_result.text = Getstringhash (Text_source.text). ToString ();
}
private void Radio32_checkedchanged (object sender, System.EventArgs e)
{
Text_result.text = gethashpassword_md5_32 (Text_source.text);
}
private void getcheckchanged ()
{
if (radio32. Checked)
{
Text_result.text = gethashpassword_md5_32 (Text_source.text);
}
else if (radio16. Checked)
{
Text_result.text = Gethashpassword_md5_16 (Text_source.text);
}
else if (radio40. Checked)
{
Text_result.text = gethashpassword_sha1_40 (Text_source.text);
}
Else
{
Text_result.text = Getstringhash (Text_source.text). ToString ();
}
}
private void Text_source_textchanged (object sender, System.EventArgs e)
{
Getcheckchanged ();
}
}
}
My station: www.gdmix.com