Crazy Test: How much time will be consume to exhaustive 16 bits numeral for all possible?

Scenario:

This is a interesting personal testing during my job. I have been had a question about code-breaking. And I always want to find out how many time will be consume if a person want to use the method of exhaustion to crack a 16 bits password.

OK, following is my testing. If someone wants to crack a 16 bits password with the method of exhaustion. He/She has to generate 16 bit sequence in real time. (Of course, you can use password dictionary instead of generate sequence in real time. But that will be took up many space on your disk.)

To simplify our question, I developed a simple code to generate 8 bits sequence with recursion.

Code:

public class Calculate implements Runnable { private Object[] seed ; private int length ; private Object begin ; public Calculate(Object[] seed, Object begin, int length) { this.seed = seed ; this.begin = begin ; this.length = length ; } public void generateStr(String str, Object[] seed) { if(str.length()==length) { // System.out.println(str) ; // Global.addCount() ; return ; } else { for(int i=0 ; i<seed.length ; i++) { String temp = str ; str = str+seed[i] ; generateStr(str, seed) ; str = temp ; } } } }  
Invoking:
Object[] seed = initCrackSeed(SeedType.NUMERAL) ;// 0,1,2,3,4,5,6,7,8,9 Calculate cal = new Calculate(seed, "" , 8) ; long startTime = System.nanoTime() ; cal.generateStr("", seed) ; long endTime = System.nanoTime() ; System.out.println("Time Consume: "+(endTime-startTime)/1000000000+" seconds.") ;   
   
   

Result:

Time Consume: 8 seconds.
Now, you can see that it will spend 8 seconds to trave all 8 bit sequence. There must be 100,000,000 possibilities. So, if someone wants to trave all possibilities for 16 bit sequence, there should be 10,000,000,000,000,000 = 100,000,000 X 100,000,000  numbers. Therefore, it’s not hard to estimate the time consuming should be 8X100,000,000=800,000,000 second.

To be clear, 800,000,000 seconds = 800,000,000/60/60/24/365 = 25.3678 years.

25 years is really a huge time consuming to generate 16 bit numeral. In this case, we didn’t consider time consuming on other resource, like Network Communication Consume, the Max of System  Continuous Running… In addition, if one password includes alphabet, numeral and punctuation, the work will be more terrible.

To summary, I think we can say that if we want to crack a 16 bit sequence, we must find out an faster way to generate these sequences. Otherwise, we have to wait untill 25 years later.

This is a quick testing for my interesting. If you have any good idea, please kindly share with me.

Thanks!

Xianyi.Ye

[email protected]

你可能感兴趣的:(object,String,System,NetWork,Dictionary,testing)