When I try to find collision in a hash value using php, there is a problem. I can find the first 3 byte collision successfully. However when I try to find the 10 byte collision the array_search does not work. It return some non match value to me. Can anyone help me? Here is my code.
<?php
$array = array();
$do = true;
do {
$num1= rand(1,90000);
$num2= rand(1,90000);
$testcase2 = $num1."14040371D".$num2;
$testcase1 = (string)$testcase2;
$hashed = (string)substr(sha1($testcase1),0,10);
//echo($testcase1."
");
$findornot = array_search($hashed,$array);
if($findornot !== false) {
$array[$testcase1] = $hashed;
echo ($findornot."
");
echo ($testcase1."
");
echo ($hashed);
$do=false;
} else {
$array[$testcase1] = $hashed;
}
//print_r(array_values($array));
}while($do)
?>