MD5 encryption of data encryption

Source: Internet
Author: User

MD5 is a secure hashing algorithm with two features:
1, enter two different plaintext (a piece of raw digital information) will not get the same output value
2, according to the output value, can not get the original plaintext, that is, the process is irreversible
So to decrypt the MD5 there is no ready-made algorithm, can only use the poor lifting method, the possible clear text, with the MD5 algorithm hash, the resulting hash value and the original data form a one-on mapping table, and then in the so-called decryption, all through the mapping table to find its corresponding original plaintext.
There is absolutely no algorithm that can calculate the original plaintext by outputting the hashed value after the encryption.

Read more about Baidu Encyclopedia:

Http://baike.baidu.com/link?url=R7WBookslKWRvprcZ6o4ZkurlXDPTaCqr6kTzT1WWIPwTgb5eRpi2e6dVXMEKoM_

Http://baike.baidu.com/link?url=HsaSyVnnJ3n2Ep2XVoSPv0SBJRvCY0Zm18MqDZIvvkJUwSZvgz4yS9upDY_YTVcVBOpUZUxFVyio4r_yY0Xq5K

MD5 encryption is irreversible. So the data is already safe, the code is as follows

MD5CryptoServiceProvider in the namespace: System.Security.Cryptography;

1    #region=======MD5 Encryption ======2         /// <summary>3         ///MD5 Encryption4         /// </summary>5         /// <param name= "Sdatain" ></param>6         /// <returns></returns>7          Public Static stringGetMD5 (stringSdatain)8         {9MD5CryptoServiceProvider MD5 =NewMD5CryptoServiceProvider ();Ten             byte[] bytvalue, Bythash; OneBytvalue = System.Text.Encoding.UTF8.GetBytes (Sdatain +"Unity3d"); ABythash =Md5.computehash (bytvalue); - MD5. Clear (); -             stringStemp =""; the              for(inti =0; i < bythash.length; i++) -             { -Stemp + = Bythash[i]. ToString ("X"). PadLeft (2,'0'); -             } +             returnstemp.tolower (); -}

Of course, you can encrypt the original password several times with MD5. Is it more secure?

1 /// <summary>2         ///Login entry for password encryption, encrypted password: s+md5 (S+MD5 (pwd))3         /// </summary>4         /// <param name= "pwd" >password entered by the user or user password stored in the database</param>5         /// <param name= "S" >randomly generate a two-bit letter: s, or you can specify the letter yourself</param>6         /// <returns></returns>7          Public Static stringEntry (stringPwdstrings)8         {9             if(string. IsNullOrEmpty (s))Ten             { OneRandom Randmon =NewRandom (); As = ((Char) Randmon. Next ( $, the)). ToString () + ((Char) Randmon. Next ( $, the)). ToString (); -             } -             returnS + GetMD5 ((s +GetMD5 (pwd )); the}

Then call entry directly ("Unity3d", "AB");

MD5 encryption of data encryption

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.