adler32 PAWN hash does not match PHP hash
#1

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.
Reply


Messages In This Thread
adler32 PAWN hash does not match PHP hash - by Chris. - 24.01.2010, 12:10
Re: adler32 PAWN hash does not match PHP hash - by legodude - 21.02.2012, 15:44
Re: adler32 PAWN hash does not match PHP hash - by iPLEOMAX - 21.02.2012, 15:53
Re: adler32 PAWN hash does not match PHP hash - by iTorran - 21.02.2012, 16:49
Re: adler32 PAWN hash does not match PHP hash - by jamesbond007 - 21.02.2012, 16:57

Forum Jump:


Users browsing this thread: 1 Guest(s)