3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function startsWith($haystack, $needle) { return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; } function find_dec_prefix($str) { $i = 0; for(;;$i++) { if ($i == 0) $newstr = $str; else $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("aaroZmOk"); $pass2 = find_dec_prefix("aaK1STfY"); var_dump(sha1($pass1) == sha1($pass2)); echo(sha1('aaroZmOk') . " == " . sha1('aaK1STfY') . "\n"); $pass3 = find_dec_prefix("suPERSecretPasSw0rD"); $pass4 = find_dec_prefix("omgDONTcollidePLEASE"); var_dump(sha1($pass3) == sha1($pass4)); echo(sha1('aaroZmOk') . " == " . sha1('aaK1STfY') . "\n");
based on 1seIK
Output for 5.3.13 - 7.2.0
doesn't contain a-f: 0e66507019969427134894567494305185566735 doesn't contain a-f: 0e76658526655756207688271159624026011393 bool(true) 0e66507019969427134894567494305185566735 == 0e76658526655756207688271159624026011393
Process exited with code 137.