两种MD5最后的值不一样,因为两种做法不一样

//MD5加密

 private static string Md5Hash(string input)
        {
            MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
            byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
            StringBuilder sBuilder = new StringBuilder();
            for (int i = 0; i < data.Length; i++)
            {
                sBuilder.Append(data[i].ToString("x2"));
            }
            return sBuilder.ToString();
        }

 

static void Main(string[] args)
        {

 

 string a = "aaaa";
            string b = "中国";
            string c = "cccc";
            int d = 1231231;
            string result1 = a + b + c + d;
          

 

 string md5result11 =System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(result1, "MD5");

string md5result111 = Md5Hash(result1).ToLower();

  Console.WriteLine(md5result11);
            Console.WriteLine(md5result111);
            Console.ReadKey();
 }

 

 

 

 

 

 结果输出如下:

注意:

1,如果将里面的中文换成英文或数字就没有问题,看来是因为两种方法针对中文的不同处理 ;

2,System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile在4.5上已经过期,即不提倡使用,但是百度翻译目前还用这个方法的加密验证sign

导致我整了好久,此处真想说百度反应真的挺慢的。。。如果要不是google被墙了,个人觉得百度应该用户量会大减;

 

如果你要是有更好的意见,请直接回复,本人为原创,请自重!转载写明请出自--清风徐徐

 

 

 

 

posted @ 2016-07-19 18:20  华强国邦  阅读(1732)  评论(0编辑  收藏  举报