C#MD5 encryption

Source: Internet
Author: User
Tags md5 encryption md5 hash

Original: http://blog.csdn.net/wonsoft/article/details/5913572

Good article: http://www.cnblogs.com/healer007/p/5062189.html

MD5 's full name is Message-digest algorithm 5 (Information-Digest algorithm, in the early 90 by MIT Laboratory for Computer Science and RSA Data Security Inc Ronald L. Rive St developed, developed by MD2, Md3 and MD4.

MD5 has a very good security (because it has irreversible characteristics, encrypted ciphertext after decryption and the same as before the encryption of the same probability)

16-bit encryption

/// <summary>///16-bit MD5 encryption/// </summary>/// <param name= "password" ></param>/// <returns></returns> Public Static stringGetMD5 (stringPassword) {    varMD5 =NewMD5CryptoServiceProvider (); stringT2 = bitconverter.tostring (Md5.computehash (Encoding.Default.GetBytes (Password)),4,8); T2= T2. Replace ("-",""); returnT2;}

32, 48, 64-bit encryption

 Private Static stringGetMD5 (stringPassword) {MD5CryptoServiceProvider MD5=NewMD5CryptoServiceProvider (); byte[] bytvalue, Bythash; Bytvalue=System.Text.Encoding.UTF8.GetBytes (Password); Bythash=Md5.computehash (Bytvalue); MD5.              Clear (); StringBuilder stemp=NewStringBuilder (password.length);  for(inti =0; i < bythash.length; i++) {stemp.append (Bythash[i]. ToString ("X"));
Stemp.append (Bythash[i]. ToString ("X3"));
Stemp.append (Bythash[i]. ToString ("X4"));
//The result of the encryption result of "X" is 32 bits, "x3" result is 48 bits, "x4" result is 64 bits } returnstemp.tostring (). ToLower (); } Static voidMain (string[] args) { varresult = GetMD5 ("123456"); Console.WriteLine (result);
}

The following are MD5 through 16-bit, 32-bit, 48-bit, 64-bit encrypted password characters

Attention:

MD5 encryption is commonly used for 32-bit encoding, and in many places will use 16-bit encoding
What difference do they have?
16-bit encryption is to extract the middle 16 bits from the 32-bit MD5 hash!
In fact, it is slower to crack 16-bit MD5 hash than to crack 32-bit MD5 hash.
Because he has one more step, is to use 32-bit encryption and then extract the middle 16 bits, and then compare.
and to crack 32-bit is not required, after the direct comparison of encryption can be!

C#MD5 encryption

Related Article

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.