MD5加密 和Sha256加密
//MD5加密
private static string GetMd5Hash(string emailAddress)
{
byte[] data = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(emailAddress));
var sBuilder = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
return sBuilder.ToString();
}
//256位散列加密
public static string Sha256(string plainText) { SHA256Managed _sha256 = new SHA256Managed(); byte[] _cipherText = _sha256.ComputeHash(Encoding.Default.GetBytes(plainText)); return Convert.ToBase64String(_cipherText); }