How to crack md5 encryption and how to crack md5 Encryption

Source: Internet
Author: User

How to crack md5 encryption and how to crack md5 Encryption
We know that md5 encryption is irreversible, but it is easy to crack md5 encryption.
There are also many online attacks. Since it is irreversible, how did the online cracking come from?
The reason is simple, that is, brute force cracking.
For example, we calculate the md5 of the combination of all characters on the keyboard, and store the encrypted strings into the database separately;
Then, use your md5 encrypted string to search for the encrypted string. This is the mystery of online cracking.
However, this method also has limitations. For example, if I perform multiple md5 encryption operations on a single string, We need to repeatedly crack it.
If you don't know how many times the string is encrypted by md5, you have to try it multiple times. Of course, the md5 encryption password used by websites is not too complex.
We can use the method I mentioned today to crack it.
1.First, we need to find all the characters on the keyboard and store them in the array, as shown below::

/*** All characters except function keys on the keyboard */static char [] buf = {'1', '2', '3', '4', '5 ', '6', '7', '8', '9', '0', 'A', 'B', 'C', 'D', 'E ', 'F', 'G', 'h', 'I', 'J', 'k', 'l', 'M', 'n', 'O ', 'P', 'Q', 'R','s ', 't', 'U', 'V', 'w', 'x', 'y ', 'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'h', 'I ', 'J', 'k', 'l', 'M', 'n', 'O', 'P', 'Q', 'R','s ', 'T', 'U', 'V', 'w', 'x', 'y', 'z ','','~ ','! ',' @ ',' # ',' $ ',' % ',' ^ ','&','*','? ',''','"',':','(',')',';',',','. ','/',' <','> ',' \ ',' | ','] ',' [',' {','};
2. The md5 calculation method is as follows::
/*** Implement md5 encryption * @ author Herman. xiong * @ date 10:19:05 * @ param str * @ return */static String md5 (String str) {StringBuffer sb = new StringBuffer (32); try {MessageDigest md = MessageDigest. getInstance ("MD5"); byte [] array = md. digest (str. getBytes ("UTF-8"); for (int I = 0; I <array. length; I ++) {sb. append (Integer. toHexString (array [I] & 0xFF) | 0x100 ). toUpperCase (). substring (1, 3) ;}} catch (Exception e) {return null ;} return sb. toString ();}
3. We need to freely combine all the characters on the keyboard, which can be repeated. The Combined Code is as follows::
/*** Recursive character combination * @ author Herman. xiong * @ date 03:35:41 */static void select (String str, char [] data) {if (1> data. length) return; for (int I = 0; I <data. length; I ++) {String result = str + data [I]; System. out. println (result); // System. out. println (md5 (result); if (result. length () <data. length) {select (result, data) ;}} public static void main (String [] args) {for (int I = 0; I <buf. length; I ++) {System. out. println (buf [I]); // System. out. println (md5 (buf [I] + ""); select (buf [I] + "", buf );}}
4. The combination of Array {"1", "2", "3"} is as follows::
1 11 111 112 113 12 121 122 123 13 131 132 133
2 21 211 212 213 22 221 222 223 23 231 232
3 31 311 312 313 32 321 322 323 33 331 332

5.Store the calculated md5 value to the database, encrypt it with md5, and then crack it.

The instance code is as follows:

Package com. herman. test; import java. security. MessageDigest;/*** we know that md5 encryption is irreversible, but it is easy to crack md5 encryption. * There are also many online attacks. Since it is irreversible, how did the online cracking come from? * The reason is simple: brute force cracking is used. * For example, calculate the md5 of all characters on the keyboard and store the encrypted strings in the database; * Then, use your md5 encrypted string to search for the encrypted string. This is the mystery of online cracking. * However, this method also has limitations. For example, if I perform multiple md5 encryption operations on a single string, We need to repeatedly crack it. * If you do not know how many times the string is encrypted by md5, you have to try it multiple times. Of course, the md5 encryption password used by websites is not too complex. * We can use the method I mentioned today to crack it. * 1. first, we need to find all the characters on the keyboard and store them in the array, as follows: * 2. the md5 calculation method is as follows: * 3. we need to freely combine all the characters on the keyboard, which can be repeated. The code combination is as follows: * 4. the combination of Array {"1", "2", "3"} is as follows: 1 11 111 112 113 12 121 122 123 13 131 132 1332 21 211 212 22 213 221 222 223 23 231 232 31 2333 311 32 312 313 33 321 322 323 5. store the calculated md5 value to the database, encrypt it with md5, and then crack it. * @ Author Herman. xiong * @ date 10:18:19 * @ version V3.0 * @ since jdk 1.6, tomcat 6.0 */public class Test {/*** all characters except function keys on the keyboard */static char [] buf = {'1', '2', '3 ', '4', '5', '6', '7', '8', '9', '0', 'A', 'B', 'C ', 'D', 'E', 'F', 'G', 'h', 'I', 'J', 'k', 'l', 'M ', 'N', 'O', 'P', 'Q', 'R', 's', 't', 'U', 'V', 'w ', 'X', 'y', 'z', 'A', 'B', 'B', 'C', 'D', 'E', 'F', 'G ', 'H', 'I', 'J', 'k', 'l', 'M', 'n', 'O', 'P', 'Q ', 'R', 's','t ', 'U', 'V', 'w', 'x', 'y', 'z ','','~ ','! ',' @ ',' # ',' $ ',' % ',' ^ ','&','*','? ',''','"',':','(',')',';',',','. ','/',' <','> ',' \ ',' | ','] ',' [',' {','}; /*** Implement md5 encryption * @ author Herman. xiong * @ date 10:19:05 * @ param str * @ return */static String md5 (String str) {StringBuffer sb = new StringBuffer (32); try {MessageDigest md = MessageDigest. getInstance ("MD5"); byte [] array = md. digest (str. getBytes ("UTF-8"); for (int I = 0; I <array. length; I ++) {sb. append (Integer. toHexString (array [I] & 0xFF) | 0x100 ). toUpperCase (). substring (1, 3) ;}} catch (Exception e) {return null ;} return sb. toString ();}/*** recursive character combination * @ author Herman. xiong * @ date 03:35:41 */static void select (String str, char [] data) {if (1> data. length) return; for (int I = 0; I <data. length; I ++) {String result = str + data [I]; System. out. println (result); // System. out. println (md5 (result); if (result. length () <data. length) {select (result, data) ;}} public static void main (String [] args) {for (int I = 0; I <buf. length; I ++) {System. out. println (buf [I]); // System. out. println (md5 (buf [I] + ""); select (buf [I] + "", buf );}}}
The Running Effect of encryption is as follows:
Welcome to my blog! If you have any questions, please join the QQ group: 135430763 to learn together!

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.