hi,
ich wollte gerade einen passwort-hash von pawn in php umschreiben, aber bekomme jetzt für fast jede zeile einen error,
dass ich nicht durch null teilen darf^^
hier mal beide codes:
pawn:
stock passwordHash(buf[]) {
new length=strlen(buf);
new a;
new s1 = 2;
new s2 = 3;
new s3 = 5;
new s4 = 7;
new s5 = 9;
new s6 = 11;
new s7 = 13;
new s8 = 17;
new s9 = 7919;
new s10 = 7907;
new s11 = 7901;
new s12 = 7883;
new s13 = 7879;
new s14 = 7877;
new s15 = 7873;
new s16 = 7867;
for (a=0; a<length; a++)
{
s1 = (s1 + buf[a]) * 65521;
s2 = (s2 / s1 + buf[a]) * 65521;
s3 = (s3 * s2 / s1 + buf[a]) * 65521;
s4 = (s4 + s3 - s2 * s1 / buf[a]) * 65521;
s5 = (s5 / s4 + s3 - s2 * s1 / buf[a]) * 65521;
s6 = (s6 * s5 / s4 + s3 - s2 * s1 / buf[a]) * 65521;
s7 = (s7 - s6 * s5 / s4 + s3 - s2 * s1 / buf[a]) * 65521;
s8 = (s8 + s7 - s6 * s5 / s4 + s3 - s2 * s1 / buf[a]) * 65521;
s9 = (s9 / s8 + s7 - s6 * s5 / s4 + s3 - s2 * s1 / buf[a]) * 65521;
s10 = (s10 * s9 / s8 + s7 - s6 * s5 / s4 + s3 - s2 * s1 / buf[a]) * 65521;
s11 = (s11 - s10 * s9 / s8 + s7 - s6 * s5 / s4 + s3 - s2 * s1 / buf[a]) * 65521;
s12 = (s12 + s11 - s10 * s9 / s8 + s7 - s6 * s5 / s4 + s3 - s2 * s1 / buf[a]) * 65521;
s13 = (s13 / s12 + s11 - s10 * s9 / s8 + s7 - s6 * s5 / s4 + s3 - s2 * s1 / buf[a]) * 65521;
s14 = (s14 * s13 / s12 + s11 - s10 * s9 / s8 + s7 - s6 * s5 / s4 + s3 - s2 * s1 / buf[a]) * 65521;
s15 = (s15 - s14 * s13 / s12 + s11 - s10 * s9 / s8 + s7 - s6 * s5 / s4 + s3 - s2 * s1 / buf[a]) * 65521;
s16 = (s16 + s15 - s14 * s13 / s12 + s11 - s10 * s9 / s8 + s7 - s6 * s5 / s4 + s3 - s2 * s1 / buf[a]) * 65521;
}
return (s16 << 128) * s1 * s2 * s3 * s4 * s5 * s6 * s7 + s8 + s9 + s10 + s11 + s12 + s13 + s14 + s15 + s16;
}
und hier der php code:
function passwordHash($buf) {
(int)$length=strlen($buf);
(int)$a;
(int)$s1 = 2;
(int)$s2 = 3;
(int)$s3 = 5;
(int)$s4 = 7;
(int)$s5 = 9;
(int)$s6 = 11;
(int)$s7 = 13;
(int)$s8 = 17;
(int)$s9 = 7919;
(int)$s10 = 7907;
(int)$s11 = 7901;
(int)$s12 = 7883;
(int)$s13 = 7879;
(int)$s14 = 7877;
(int)$s15 = 7873;
(int)$s16 = 7867;
for ($a=0; $a<$length; $a++)
{
$s1 = ($s1 + $buf[$a]) * 65521;
$s2 = ($s2 / $s1 + $buf[$a]) * 65521;
$s3 = ($s3 * $s2 / $s1 + $buf[$a]) * 65521;
$s4 = ($s4 + $s3 - $s2 * $s1 / $buf[$a]) * 65521;
$s5 = ($s5 / $s4 + $s3 - $s2 * $s1 / $buf[$a]) * 65521;
$s6 = ($s6 * $s5 / $s4 + $s3 - $s2 * $s1 / $buf[$a]) * 65521;
$s7 = ($s7 - $s6 * $s5 / $s4 + $s3 - $s2 * $s1 / $buf[$a]) * 65521;
$s8 = ($s8 + $s7 - $s6 * $s5 / $s4 + $s3 - $s2 * $s1 / $buf[$a]) * 65521;
$s9 = ($s9 / $s8 + $s7 - $s6 * $s5 / $s4 + $s3 - $s2 * $s1 / $buf[$a]) * 65521;
$s10 = ($s10 * $s9 / $s8 + $s7 - $s6 * $s5 / $s4 + $s3 - $s2 * $s1 / $buf[$a]) * 65521;
$s11 = ($s11 - $s10 * $s9 / $s8 + $s7 - $s6 * $s5 / $s4 + $s3 - $s2 * $s1 / $buf[$a]) * 65521;
$s12 = ($s12 + $s11 - $s10 * $s9 / $s8 + $s7 - $s6 * $s5 / $s4 + $s3 - $s2 * $s1 / $buf[$a]) * 65521;
$s13 = ($s13 / $s12 + $s11 - $s10 * $s9 / $s8 + $s7 - $s6 * $s5 / $s4 + $s3 - $s2 * $s1 / $buf[$a]) * 65521;
$s14 = ($s14 * $s13 / $s12 + $s11 - $s10 * $s9 / $s8 + $s7 - $s6 * $s5 / $s4 + $s3 - $s2 * $s1 / $buf[$a]) * 65521;
$s15 = ($s15 - $s14 * $s13 / $s12 + $s11 - $s10 * $s9 / $s8 + $s7 - $s6 * $s5 / $s4 + $s3 - $s2 * $s1 / $buf[$a]) * 65521;
$s16 = ($s16 + $s15 - $s14 * $s13 / $s12 + $s11 - $s10 * $s9 / $s8 + $s7 - $s6 * $s5 / $s4 + $s3 - $s2 * $s1 / $buf[$a]) * 65521;
}
return ($s16 << 128) * $s1 * $s2 * $s3 * $s4 * $s5 * $s6 * $s7 + $s8 + $s9 + $s10 + $s11 + $s12 + $s13 + $s14 + $s15 + $s16;
}
Alles anzeigen
vlt kann mir ja jemand weiterhelfen.
danke schonmal
mfg Marshall