一、引用命名空间
using System.Security.Cryptography;
二、核心代码
private void button1_Click(object sender, EventArgs e)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] data = System.Text.Encoding.Default.GetBytes(textBox1.Text);
byte[] md5data = md5.ComputeHash(data);
md5.Clear();
string st = "";
for (int i = 0; i < md5data.Length - 1; i++)
{
st += md5data[i].ToString("x").PadLeft(2, ‘0‘);
}
textBox2.Text = st;
}
三、界面显示
原文地址:http://blog.csdn.net/lucky51222/article/details/27373223