05.04.2011, 17:12
(
Последний раз редактировалось Johnson_boy; 18.05.2011 в 16:23.
)
I need help with converting this to php:
I've tried:
But it does not return same value.
pawn Код:
stock num_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
PHP код:
function num_hash($string)
{
$length = strlen($string);
$s1 = 1;
$s2 = 0;
for($n = 0; $n < $length; $n++)
{
$s1 = strval(($s1 + $string[$n]) % 65521);
$s2 = strval(($s2 + $s1) % 65521);
}
echo ($s2 << 16) + $s1;
}