MD5CryptoServiceProvider已过时:Derived cryptographic types are obsolete. Use the Create method on the base type instead
解决方案:使用MD5.Create
C# 全选
/// <summary>
/// MD5加密,不可逆
/// </summary>
/// <param name="input">明文字符串</param>
/// <returns></returns>
public static string ToMD5(string input)
{
using (MD5 md5 = MD5.Create())
{
byte[] inputBytes = Encoding.ASCII.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")); // Convert to hexadecimal
}
return sb.ToString().ToLower();
}
}
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网