The last value of the two MD5 is different because the two approaches are different

Source: Internet
Author: User

MD5 encryption

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 = "China";
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 (); }

The resulting output is as follows:

Attention:

1, if there is no problem in converting the Chinese into English or numbers, it seems that the two methods are different for Chinese.

2,system.web.security.formsauthentication.hashpasswordforstoringinconfigfile in 4.5 has expired, that is not advocated use, but Baidu translation is still using this method of encryption to verify sign

Cause I was a long time, here really want to say that Baidu reaction really very slow ... If it is not Google by the wall, the individual feel that Baidu should be greatly reduced user volume;

If you have a better opinion, please reply directly, I am original, please self-esteem! Reprint, please come from--the breeze slowly

The last value of the two MD5 is different because the two approaches are different

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.