[HELP] num_hash problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] num_hash problem (
/showthread.php?tid=264067)
[HELP] num_hash problem -
Ricop522 - 24.06.2011
I want to transform this to PHP.
anyone can help-me ?
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;
}
Re: [HELP] num_hash problem - rjjj - 24.06.2011
It's not a PHP Forum
.
I think It will solve your problem
.
Код:
function num_hash($buf)
{
$length = strlen($buf);
$s1 = 0;
$s2 = 0;
$n = 0;
while($n < $length)
{
$s1 = ($s1 + ord($buf[$n])) % 65521;
$s2 = ($s2 + $s1) % 65521;
$n++;
}
return ($s2 << 16) + $s1;
}
I hope that i have helped
.