Location: PHPKode > scripts > Text Iterator > text-iterator/example2.php
<?php
/**
* Brute Force Search Class
*
*
*     __     __)               _____                      ___
*    (, /|  /  ,              (, /     /)           ,    (,   )      /)    /)
*      / | /    ___   _         /  ___(/   _   __            / _   _(/  _ (/
*   ) /  |/  _(_// (_(_(_   ___/__(_) / )_(_(_/ (__(_      _/_(_(_(_(__(/_/ )_
*  (_/   '                /   /                         )   /
*                        (__ /                         (__ /
* ****************************************************************************
* @author    Nima Johari Zadeh <nijoza91-at-gmail-dot-com>
* @package   Brute Force Search Class
* @file      example2.php
* @copyright (c) 2007 Nima Johari Zadeh
* ****************************************************************************
* Allright! We gonna use this class to find a md5 output!
* We will search for db088d7fd61422d0dd9f2152fd550127
* which is actually md5 string of nima
*/

@set_time_limit(0); //This might be useful. Searching might take too long!

require_once("brute_force.class.php");

function check_md5($md5, $i)
{
    if(md5($md5) == "db088d7fd61422d0dd9f2152fd550127")
    {   
        echo "Hey! I finally found it after searching total of $i strings! it's \"$md5\" you are looking for! (without quotes)\n";
        return true;
    }
}

$brute_force = new brute_force("check_md5", 3, 4, "lower") or die($brute_force->errormsg()); //We are searching for 3 and 4 length strings which contain only lowercase characters!
$brute_force->callback_break = true; //By setting this to true, process will terminate whenever callback function returns true (refer to the documentation)
$brute_force->search();
?>
Return current item: Text Iterator