udb_hash DUDB
#1

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;
}
Reply
#2

This is not a PHP Help Forum !
Reply
#3

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

People come here to learn how to code Pawno not PHP !
Reply
#5

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
Reply
#6

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

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;
	}
Reply
#8

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
Reply
#9

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


Forum Jump:


Users browsing this thread: 1 Guest(s)