MD5 md5Hash = MD5.Create();
string pwd = txtPwd.Text.Trim();
string hashPassWord = GetMd5Hash(md5Hash, pwd);
#region MD5哈希方法GetMd5Hash(MD5 md5Hash, string input)
/// <summary>
/// MD5哈希方法
/// </summary>
/// <param name="md5Hash">MD5对象</param>
/// <param name="input">需要被哈希计算的字符串</param>
/// <returns></returns>
protected static string GetMd5Hash(MD5 md5Hash, string input)
{
byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
return sBuilder.ToString();
}
#endregion