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