Create a Windows application and add two textbox text boxes and one button;
2. Add a class MD5 and introduce the namespace: using system. Security. cryptography. The class MD5 code is as follows:
Using system;
Using system. Collections. Generic;
Using system. text;
Using system. Security. cryptography;
Namespace windows
{
Class MD5
{
Public static string encryptcode (string password)
{
Byte [] clearbytes = new unicodeencoding (). getbytes (password );
Byte [] hashedbytes = (hashalgorithm) cryptoconfig. createfromname ("MD5"). computehash (clearbytes );
Return bitconverter. tostring (hashedbytes );
}
}
}
Then write the following code in the form button event:
Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Using system. Security. cryptography;
Namespace windowsapplication1
{
Public partial class form1: Form
{
Public form1 ()
{
Initializecomponent ();
}
Private void button#click (Object sender, eventargs E)
{
Textbox2.text = md5.encryptcode (textbox1.text). Replace ("-","");
}
}
}
F5, an MD5 encryption program is OK.