adler32 PAWN hash does not match PHP hash - 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)
+--- Thread: adler32 PAWN hash does not match PHP hash (
/showthread.php?tid=123043)
adler32 PAWN hash does not match PHP hash -
Chris. - 24.01.2010
Hey,
I'm currently having some problems with adler32. I'm trying to hash a password in PHP with adler32 then matching the hash with one hashed in my gamemode.
Here is the adler32 function I'm using for PHP:
PHP код:
function Toadler32($buf)
{
$lenght = strlen($buf);
$str = str_split($buf);
$s1 = 1;
$s2 = 0;
for($n=0; $n<$lenght; $n++)
{
$s1 = ($s1 + $str[$n])% 65521;
$s2 = ($s2 + $s1) % 65521;
}
return ($s2 << 16) + $s1;
}
This is the adler32 function I'm using in my gamemode:
pawn Код:
adler32(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;
}
For example, if I hash "testing" in PAWN, the hash returns as
203293439 but when I hash it in PHP it returns as
458753. I'm not sure why it's doing this, I believe it should be returning the same hash. I've been searching for any solutions but haven't found any. Any help would be greatly appreciated.
Thanks.
Re: adler32 PAWN hash does not match PHP hash -
legodude - 21.02.2012
I think str_split has something to do with it.
Re: adler32 PAWN hash does not match PHP hash -
iPLEOMAX - 21.02.2012
Use this include:
https://sampforum.blast.hk/showthread.php?tid=319574
Re: adler32 PAWN hash does not match PHP hash -
iTorran - 21.02.2012
People should really start checking topic dates, hehe.
Re: adler32 PAWN hash does not match PHP hash -
jamesbond007 - 21.02.2012
Quote:
Originally Posted by ******
Yes they should. I don't even understand how you can accidentally find a topic two years old - surely that would be on page 2000+?
|
search engines?