24.01.2010, 12:10
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:
This is the adler32 function I'm using in my gamemode:
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.
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;
}
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;
}
Thanks.