ASP.NET MD5加密

 protected void Button1_Click(object sender, EventArgs e)
    {
        string pwd = TextBox2.Text.Trim();
        Response.Write(JMMD5A(pwd) + "{}" + JMMD5B(pwd));

    }


    public static string JMMD5A(string toCryString)
    {
        return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(toCryString, "MD5");
    }
    public static string JMMD5B(string str)
    {
        System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
        byte[] result = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(str));
        string str2 = "";
        for (int i = 0; i < result.Length; i++)
        {
            str2 += string.Format("{0:x}", result[i]);
        }
        return str2;
    }

 

posted @ 2017-11-21 16:28  enych  阅读(384)  评论(0编辑  收藏  举报