public class EncryptMethods { /// <summary> /// Md5加密 /// </summary> /// <param name="str">时间+随机数+令牌</param> /// <returns></returns> public string EncryptToMD5(string str) { MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); byte[] str1 = Encoding.UTF8.GetBytes(str); byte[] str2 = md5.ComputeHash(str1, 0, str1.Length); md5.Clear(); (md5 as IDisposable).Dispose(); return Convert.ToBase64String(str2); }
}
//调用MD5加密方法
EncryptMethods ec = new EncryptMethods();//实例化 dto.PassWord = ec.EncryptToMD5(dto.PassWord);