添加引用:using System.Security.Cryptography;


代码:

class Md5Cyption
{
    public static string Encrypt16(string strPwd)
    {

        MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
        string t2 = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(strPwd)), 4, 8);
        t2 = t2.Replace("-", "");
        return t2.ToLower();
    }

    public static string Encrypt32(string strPwd)
    {
        MD5 md5 = new MD5CryptoServiceProvider();
        byte[] data = System.Text.Encoding.Default.GetBytes(strPwd);
        byte[] md5data = md5.ComputeHash(data);
        md5.Clear();
        string str = "";
        for (int i = 0; i < md5data.Length - 1; i++)
        {
            str += md5data[i].ToString("x").PadLeft(2, '0');
        }
        return str.ToLower();

    }
}

相关文章:

  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-18
  • 2021-12-30
  • 2022-02-17
  • 2022-01-24
  • 2021-11-11
相关资源
相似解决方案