optimization - Optimize SHA256 checking in php -
i have sha256
hash text, , know original text string , consist of 0-9 numbers , letters a-z, a-z in range (000000-zzzzzz).
this code checks possible options, , returns original text code working long time (for example if string length 5 works 30 minutes, case if length 6 works 30*62 minutes ) , think not best solution case. please optimize it.
$count=0; $start_date =microtime(true); $s=array(0,1,2,3,4,5,6,7,8,9,"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"); for($g=0;$g<62;$g++) { for($h=0;$h<62;$h++) { for($i=0;$i<62;$i++) { for($j=0;$j<62;$j++) { for($k=0;$k<62;$k++) { for($l=0;$l<62;$l++) { $count++; if (hash("sha256",$s[$g].$s[$h].$s[$i].$s[$j].$s[$k].$s[$l])=='0a482c589594109cea209233a1f3bfa51f8a52e4534c40e9511c6030ee0f594a')// string zzzzzz { echo $s[$g].$s[$h].$s[$i].$s[$j].$s[$k].$s[$l]."<br/>"; echo $count."<br/>"; $end_date =microtime(true); echo ($end_date-$start_date)/60; break(6); } } } } } } }
you can't optimize break 0-9a-za-z
fastest. of course can optimize code little (also change php python or faster), gave boost 30 minutes 10 minutes 5 chars. 6 chars needs 6 hours. , 7 chars measured in days. 8 chars in years etc. it's impossible faster.
you should know sha256 method of encryption, in assumption not allow decrypt, that's purpose of method. unfortunately (fortunately you), in case of short strings it's possible decrypt in short time.
Comments
Post a Comment