- substr: documentation ( source)
- var_dump: documentation ( source)
- sha1: documentation ( source)
- preg_match: documentation ( source)
- strrpos: documentation ( source)
<?php
function startsWith($haystack, $needle) {
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;
}
function find_dec_prefix($str) {
$i = 0;
for(;;$i++) {
$newstr = $str . $i;
$hash = sha1($newstr);
if($hash[0] == '0' && $hash[1] == 'e') {
// echo "Found it: [" . $newstr . "] " . $hash . "\n";
// echo "subs: " . substr($hash, 2) . "\n";
if(!preg_match("/[a-f]/", substr($hash, 2))) {
echo "doesn't contain a-f: $hash\n";
return $newstr;
}
}
}
}
$pass1 = find_dec_prefix("suPERSecretPasSw0rD");
$pass2 = find_dec_prefix("omgDONTcollidePLEASE");
var_dump(sha1($pass1) == sha1($pass2));
echo(sha1('aaroZmOk') . " - " . sha1('aaK1STfY') . "\n");