I have this function in the scripting language "PAWN":
stock hash(Hash[])
{
new
hStr1 = 1, hStr2 = 0;
for(new i = 0, l = strlen(Hash); i < l; i ++)
{
hStr1 = (hStr1 + Hash[i]) % 65521;
hStr2 = (hStr2 + hStr1) % 65521;
}
return (hStr2 << 16) + hStr1;
}
This will output:
printf("%d", hash("Test"));
= 64815521 returns it as an integer
This is the PHP function:
function hashEX($Hash)
{
$hStr1 = 1; $hStr2 = 0;
for($i = 0, $l = strlen($Hash); $i < $l; $i ++)
{
$hStr1 = ($hStr1 + $Hash[$i]) % 65521;
$hStr2 = ($hStr2 + $hStr1) % 65521;
}
return ($hStr2 << 16) + $hStr1;
}
This gives me:
echo intval(hashEX("Test"));
= 262145
echo hashEX("Test");
= 262145
Anyone know why is this and how to fix it? To make it clear, I want to get the same value as the PAWN function in the PHP function.