Пример #1
0
function decode_string($instr)
{
    global $offsets;
    //echo "<P>DECODE <BR>";
    $orig = "";
    for ($i = 0; $i < strlen($instr); $i += 2) {
        //echo "<P>";
        $ch1 = substr($instr, $i, 1);
        $ch2 = substr($instr, $i + 1, 1);
        $val = hextoint($ch1) * 16 + hextoint($ch2);
        //echo "decoding \"" . $ch1 . $ch2 . "\" = $val <br>\n";
        $j = $i / 2 % count($offsets);
        //echo "Using offsets $j = " . $offsets[$j] . "<br>";
        $newval = $val - $offsets[$j] + 256;
        $newval %= 256;
        //echo " neval \"$newval\" <br>\n";
        $dec_ch = chr($newval);
        //echo " which is \"$dec_ch\" <br>\n";
        $orig .= $dec_ch;
    }
    return $orig;
}
function decode_string($instr)
{
    global $offsets;
    $cntOffsets = count($offsets);
    $orig = '';
    for ($i = 0, $cnt = strlen($instr); $i < $cnt; $i += 2) {
        $orig .= chr((hextoint(substr($instr, $i, 1)) * 16 + hextoint(substr($instr, $i + 1, 1)) - $offsets[$i / 2 % $cntOffsets] + 256) % 256);
    }
    return $orig;
}