using System.Text;
using System.Security.Cryptography;
public void DoMD5(string input)
{
string encrypted = [color=#4000FF]EnCryptToMD5[/color](txtpassword.text);
Response.Write(encrypted );
}
public static string EnCryptToMD5(string input)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] bs = System.Text.Encoding.UTF8.GetBytes(input);
bs = md5.ComputeHash(bs);
StringBuilder sb = new StringBuilder();
foreach (byte b in bs)
{
sb.Append(b.ToString("x2").ToLower());
}
return sb.ToString();
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น