[Help] Pawno ==> PHP
#1

Hello,

i need to convert one function from pawno to php, i tried to do it like this

Pawno code:

Код:
stock num_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;
}
PHP code:

Код:
function cryptpw($buf)

	{

	$length=strlen($buf);
    $s1 = 1;
    $s2 = 0;
    $n;
    for ($n=0; $n<$length; $n++) {
       $s1 = ($s1 + $buf[$n]) % 65521;
       $s2 = ($s2 + $s1)     % 65521;
    	}
	
		return ($s2 << 16) + $s1;

	}
but it doesnt work, if someone knows how please tell me
Reply
#2

here

PHP код:
function cryptpw($buf) {
    return 
hash('adler32'$buf);

Just check that list (a bit down on the page) which hash functions are supported
Reply
#3

doesnt works
Reply
#4

tested it, it seemed that the hash was converted to hex

Just convert it back
PHP код:
function cryptpw($buf) {
    return 
hexdec(hash('adler32'$buf));

Have fun
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)