用MD5怎么加密?

解决方案 »

  1.   

     byte[] MD5hash (byte[] data)
     {
        MD5 md5 = new MD5CryptoServiceProvider();
        byte[] result = md5.ComputeHash(data);
        return result;
     }
      

  2.   

    /// <summary>
            /// 用Md5进行加密
            /// </summary>
            /// <param name="Str"></param>
            /// <returns></returns>
            public static string EncryptMD5(string Str)
            {
                return FormsAuthentication.HashPasswordForStoringInConfigFile(Str, "MD5").ToLower();
            }        /// <summary>
            /// 用SHA1方式进行加密
            /// </summary>
            /// <param name="Str"></param>
            /// <returns></returns>
            public static string EncryptSHA1(string Str)
            {
                return FormsAuthentication.HashPasswordForStoringInConfigFile(Str, "SHA1").ToLower();
            }
      

  3.   

    FormsAuthentication命名空间在System.Web.Security;中
      

  4.   

    string pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text.ToString().Replace(" ", ""), "MD5").ToString();//密码文本框TextBox1,MD5加密
      

  5.   

    public string MD5(String str) 

    MD5 md5 = new MD5CryptoServiceProvider(); 
    byte[] data = System.Text.Encoding.Default.GetBytes(str); 
    byte[] result = md5.ComputeHash(data); 
    string s= BitConverter.ToString(result);
    return s; 

      

  6.   

    return FormsAuthentication.HashPasswordForStoringInConfigFile(Str, "MD5").ToLower()
    简单明了
      

  7.   


    public string EncryptStr(string PWD, int Format)
        {
            string str = "";
            switch (Format)
            {
                case 0:
                    str = FormsAuthentication.HashPasswordForStoringInConfigFile(PWD, "SHA1");
                    break;
                case 1:
                    str = FormsAuthentication.HashPasswordForStoringInConfigFile(PWD, "MD5");
                    break;
            }
            return str;
        }
    其实这种问题。。最好是问百度、谷歌。。不过你要散分那大家都没意见学编程首先要学会利用这几个强大的搜索引擎要不浪费资源了