MD5 加密

 

/// <summary>
/// MD5加密
/// </summary>
/// <param name="value">需要加密的值</param>
/// <param name="pwSalt">附加值</param>
/// <returns></returns>
public static string GetMD5(string value, string pwSalt)
{
HashAlgorithm hashAlgorithm = new MD5CryptoServiceProvider(); // or SHA1CryptoServiceProvider();
byte[] result = hashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(pwSalt+value));

StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i < result.Length; i++)
{
sBuilder.Append(result[i].ToString("x2"));
}
return sBuilder.ToString();
}

  

 

posted @ 2015-07-05 20:40  巫威  阅读(395)  评论(0编辑  收藏  举报