using System.Security.Cryptography;
//加密
MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
string password = this.txtPass.Text.Trim();
byte[] bits = Encoding.ASCII.GetBytes(password);
bits = provider.ComputeHash(bits);
string changePass = System.BitConverter.ToString(bits);
//保存changePass
//验证时 先加密再比较
MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
string password = this.txtPass.Text.Trim();
byte[] bits = Encoding.ASCII.GetBytes(password);
bits = provider.ComputeHash(bits);
string changePass = System.BitConverter.ToString(bits);
string pass = this.txtMd5.Text.Trim();
this.txtResult.Text = pass.CompareTo(changePass).ToString();