C#下MD5加密
直接复制下面代码传参然后返回结果即可,建议在传参时候加入干扰码,例如密码为123456干扰码为xsq.,则传入参数时候应该为123456xsq.,然后密码对照时候也进行相应处理即可,简单好用高效。
/// <summary>
/// MD5加密
/// </summary>
public class Safe
{
public static string ConvertToMD5(string input)
{
MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.Text.Encoding.UTF8.GetBytes(input);
byte[] hashBytes = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("x2"));
}
return sb.ToString();
}
}