SA-MP Forums Archive
udb_hash DUDB - 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: udb_hash DUDB (/showthread.php?tid=127482)



udb_hash DUDB - gernes - 13.02.2010

Hello,

I have a problem with DUDB from dracoblua. I want udb_hash in php, but returns me to a different value (excuse me for the translation [****** translator]). I got it as follows:

Код:
function _udbhash( $pass )
{
  $length = strlen($pass);
  $s1 = 1;
  $s2 = 0;
  
  for($i=0; $i<$length; $i++)
  {
   $s1 = ($s1 + $pass[$i]) % 65521;
   $s2 = ($s2 + $s1)    % 65521;
  }
  return ($s2 << 16) + $s1;  
}
on dudb.inc SAMP:

Код:
stock udb_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: udb_hash DUDB - xCoder - 13.02.2010

This is not a PHP Help Forum !


Re: udb_hash DUDB - gernes - 13.02.2010

this is recoded PAWN dracoblue SAMP script to PHP ....omg !!


Re: udb_hash DUDB - xCoder - 13.02.2010

People come here to learn how to code Pawno not PHP !


Re: udb_hash DUDB - Luka P. - 10.03.2010

Quote:
Originally Posted by CoverH.ng
People come here to learn how to code Pawno not PHP !
Shut the fuck up already

@Frenk
can you please say me what does php function returns


Re: udb_hash DUDB - mick88 - 31.03.2010

I have the same problem. The thing is, in PHP forum peolple won't understand PAWN and send us to PAWN forum and vice versa. So if anyone could just explain these two lines:

Код:
$s1 = ($s1 + $buf[$n]) % 65521;
$s2 = ($s2 + $s1)   % 65521;
(i don't know what % does) and maybe I'd be able to script that in PHP.

Also I think the problem may be "<<" which in PAWNO is for power while in PHP might be something else...


Re: udb_hash DUDB - mick88 - 07.04.2010

OK, thanks to my brother, we have the solution. Hope it helps:

Код:
function udb_hash($pass)
	{
		$length = strlen($pass);
	  $s1 = 1;
	  $s2 = 0;
	  
	  for($i=0; $i<$length; $i++)
	  {
	   $s1 = ($s1 + ord($pass[$i])) % 65521;
	   $s2 = ($s2 + $s1)    % 65521;
	  }
	  $wy= ($s2 << 16) + $s1;
		return $wy;
	}



Re: udb_hash DUDB - Scienziatopazzo - 18.06.2012

Quote:
Originally Posted by mick88
Посмотреть сообщение
OK, thanks to my brother, we have the solution. Hope it helps:

Код:
function udb_hash($pass)
	{
		$length = strlen($pass);
	  $s1 = 1;
	  $s2 = 0;
	  
	  for($i=0; $i<$length; $i++)
	  {
	   $s1 = ($s1 + ord($pass[$i])) % 65521;
	   $s2 = ($s2 + $s1)    % 65521;
	  }
	  $wy= ($s2 << 16) + $s1;
		return $wy;
	}
Thanks, you are the best


Re: udb_hash DUDB - Revo - 18.06.2012

Quote:
Originally Posted by mick88
Посмотреть сообщение
I have the same problem. The thing is, in PHP forum peolple won't understand PAWN and send us to PAWN forum and vice versa. So if anyone could just explain these two lines:

Код:
$s1 = ($s1 + $buf[$n]) % 65521;
$s2 = ($s2 + $s1)   % 65521;
(i don't know what % does) and maybe I'd be able to script that in PHP.

Also I think the problem may be "<<" which in PAWNO is for power while in PHP might be something else...
% = remainder by division.
http://en.wikipedia.org/wiki/Modulo_operation

'In computing, the modulo operation finds the remainder of division of one number by another.'