你的位置:首页 > ASP.net教程

[ASP.net教程].net MD5加密


     /// <summary>    /// MD5加密    /// </summary>    /// <param name="input">需要加密的字符串</param>    /// <returns></returns>    public static string MD5Encrypt(string input)    {      return MD5Encrypt(input, new UTF8Encoding());    }    /// <summary>    /// MD5加密    /// </summary>    /// <param name="input">需要加密的字符串</param>    /// <param name="encode">字符的编码</param>    /// <returns></returns>    public static string MD5Encrypt(string input, Encoding encode)    {      MD5 md5 = new MD5CryptoServiceProvider();      byte[] t = md5.ComputeHash(encode.GetBytes(input));      StringBuilder sb = new StringBuilder(32);      for (int i = 0; i < t.Length; i++)        sb.Append(t[i].ToString("x").PadLeft(2, '0'));      return sb.ToString();    }