Esempio n. 1
0
function base64decoding($string)
{
    global $base64ids;
    $string = str_replace("=", "", $string);
    $binary = "";
    for ($i = 0; $i < strlen($string); $i++) {
        $charID = array_search($string[$i], $base64ids);
        $idBIN = decToBin($charID);
        if (strlen($idBIN) != 6) {
            $idBIN = str_repeat("0", 6 - strlen($idBIN)) . $idBIN;
        }
        $binary .= $idBIN;
    }
    if (strlen($binary) % 8 != 0) {
        $binary = substr($binary, 0, strlen($binary) - strlen($binary) % 8);
    }
    $array = array();
    for ($j = 0; $j < strlen($binary); $j = $j + 8) {
        $part = substr($binary, $j, 8);
        array_push($array, $part);
    }
    $text = "";
    foreach ($array as &$value) {
        $value = binToDec($value);
        $value = chr($value);
        $text .= $value;
    }
    return $text;
}
Esempio n. 2
0
function getCatFunctionFromName($name, $index)
{
    global $l_s;
    global $l_index;
    $l = $l_index;
    $l_index = $index;
    if ($name == "b") {
        $l_s = array('0');
        for ($i = 0; $i < floor(($l_index + 1) / 2); ++$i) {
            $l_s[] = '0';
            $l_s[] = '1';
        }
        return array(function ($x) {
            global $l_s;
            global $l_index;
            return $x * pow(2, $l_index) - (binToDec($l_s) - 1);
        }, "*" . pow(2, $l_index) . "-" . (binToDec($l_s) - 1), floor($l_index / 2) + 1, "*" . (floor($l_index / 2) + 1));
    } else {
        if ($name == "a") {
            $l_s = array('1');
            for ($i = 0; $i < floor(($l_index - 1) / 2); ++$i) {
                $l_s[] = '0';
                $l_s[] = '1';
            }
            return array(function ($x) {
                global $l_s;
                global $l_index;
                return ($x + (binToDec($l_s) + 1)) / pow(2, $l_index);
            }, "+" . (binToDec($l_s) + 1) . "/" . pow(2, $l_index), floor($l_index / 2 + 1), "/" . (floor($l_index / 2) + 1));
        } else {
            return array("hallo welt", "hadsf", "hsdaf", "jdskag");
        }
    }
}