Hi,
I wish to port the ip decrypter to PHP, but i have some problems with getting the correct output. I'm just starting with php, have no knowledge of c++ and havent got much experience with bitwise operations too. In short: I need someone's help.
Code:
<?PHP
function ipdec($ipchar) {
$answer = 15;
switch ($ipchar) {
case 'a': $answer = 0;
case 'F': $answer = 1;
case 'l': $answer = 2;
case '4': $answer = 3;
case 'u': $answer = 4;
case 'O': $answer = 5;
case 'D': $answer = 6;
case '9': $answer = 7;
case 's': $answer = 8;
case 'f': $answer = 9;
case 'W': $answer = 10;
case 'q': $answer = 11;
case '1': $answer = 12;
case 'v': $answer = 13;
case 'G': $answer = 14;
}
return $answer;
}
function ipdecoder($ip) {
$answer = 0;
$answer |= ipdec($ip[1]) << 28;
$answer |= ipdec($ip[2]) << 24;
$answer |= ipdec($ip[3]) << 20;
$answer |= ipdec($ip[4]) << 16;
$answer |= ipdec($ip[5]) << 12;
$answer |= ipdec($ip[6]) << 8;
$answer |= ipdec($ip[7]) << 4;
$answer |= ipdec($ip[8]);
$answer ^= 0xc3801dc7;
return $answer;
}
$ipdecode = 'XWDusGvauX';
echo long2ip(ipdecoder($ipdecode));
?>