1. 程式人生 > >使用PHP中破解md5密碼(迴圈:10萬個/3秒)

使用PHP中破解md5密碼(迴圈:10萬個/3秒)



十萬位 --》2.7086160183 seconds

程式碼:


MD5迴圈<br>
00000到100000(10萬位)<br>
例子:
[url]http://.........php?str=55555[/url]
(限5位數)<br>

<?php
$time_start = getmicrotime();
if (!$str){exit;}
echo $str."的MD5值為:";
$mdstr = md5($str);
echo  $mdstr."<br>";
echo "開始迴圈";

function b() {
global $mdstr;
for($i=0;$i<=100000;$i++)
{
$i = str_pad($i, 5, '0', STR_PAD_LEFT);
if (md5($i) === $mdstr) {
   echo "<br>破解結果--->";
   echo $i;
   c();
   exit;
}
}
}
b();
function c() {
global $time_start;
$time_end = getmicrotime();
$time = $time_end - $time_start;
echo "<br><br><br>Did nothing in $time seconds<br>";//輸出執行總時間
}
function getmicrotime(){
   list($usec, $sec) = explode(" ",microtime());
   return ((float)$usec + (float)$sec);
   }
?>