[Help] Pawno ==> PHP - 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: [Help] Pawno ==> PHP (
/showthread.php?tid=288968)
[Help] Pawno ==> PHP -
jimmyC - 09.10.2011
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
AW: [Help] Pawno ==> PHP -
Nero_3D - 09.10.2011
here
PHP код:
function cryptpw($buf) {
return hash('adler32', $buf);
}
Just check that
list (a bit down on the page) which hash functions are supported
Re: [Help] Pawno ==> PHP -
jimmyC - 09.10.2011
doesnt works
AW: [Help] Pawno ==> PHP -
Nero_3D - 10.10.2011
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