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
#2

I think str_split has something to do with it.
Reply
#3

Use this include: https://sampforum.blast.hk/showthread.php?tid=319574
Reply
#4

People should really start checking topic dates, hehe.
Reply
#5

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


Forum Jump:


Users browsing this thread: 1 Guest(s)