Encodes the ChromeLogger-compatible data-structure in JSON/base64-format

@param array $data header data

@return string
541801
protected function encodeData(array $data): string
    {
        $json = \json_encode(
            $data,
            JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
        );

        return \base64_encode($json);
    }
759166
public static function decode($data)
    {
        $rData = strtr($data, '-_', '+/');
        $rMod4 = strlen($rData) % 4;
        if ($rMod4) {
            $rData .= substr('====', $rMod4);
        }
        return base64_decode($rData);
    }
1297418
public static function encodePhpSerialize( array $data ) {
		try {
			return serialize( $data );
		} catch ( \Exception $ex ) {
			self::$logger->error( 'PHP serialization failed: ' . $ex->getMessage() );
			return null;
		}
	}
101338
public function encrypt($data): string
    {
        if (!$this->password)
        {
            return JSON::encode($data);
        }

        return $this->security()
            ->encrypt(JSON::encode($data));
    }
186208
public function encodeOutput($data)
    {
        // TODO - use HTTP_ACCEPT here ?
        //var_dump($_SERVER['HTTP_ACCEPT']);

        if ($_GET['format'] == 'xml') {
            throw $this->exception('only JSON format is supported', null, 406);
        }

        if ($_GET['format'] == 'json_pretty') {
            header('Content-type: application/json');
            echo json_encode($data, JSON_PRETTY_PRINT);
            return;
        }

        if ($_GET['format'] == 'html') {
            echo '<pre>';
            echo json_encode($data, JSON_PRETTY_PRINT);
            return;
        }

        header('Content-type: application/json');

        if ($data === null) {
            $data = array();
        }
        echo json_encode($data);
    }
894568
public function encode($data): string
    {
        $encoded = @json_encode($data, $this->getEncodeOptions());

        if ($encoded === false && json_last_error() !== JSON_ERROR_NONE) {
            throw new \RuntimeException('Encoding JSON failed: ' . json_last_error_msg());
        }

        return $encoded;
    }
250067
public function decode($data)
    {
        $decoded    = '';
        $delimiters = "\n";
        $token      = strtok($data, $delimiters);

        while (false !== $token) {
            $decoded .= base64_decode($token);

            $token = strtok($delimiters);
        }

        return $decoded;
    }
51019
public static function encodeURLSafe($data)
    {
        $encoded = base64_encode($data);

        if ($encoded === false) {
            return false;
        }

        return str_replace(array('+', '/', '='), array('-', '_', ''), $encoded);
    }
329995
protected function encode($data)
    {
        if(null === $this->formatHandlerClass)
        {
            return $data;
        }
        else if(RequestContext::exsits() && null !== RequestContext::getServer())
        {
            return RequestContext::getServerBean($this->formatHandlerClass)->encode($data);
        }
        else
        {
            return App::getBean($this->formatHandlerClass)->encode($data);
        }
    }
131823
public static function base64( $data, $encode = 0 ) {
		$out = $encode ? base64_encode( $data ) : base64_decode( $data );

		return $out;
	}
917928
public static function encode($data)
    {
        switch (gettype($data)) {
            case 'array':
                return self::encodeArray($data);
            case 'object':
                return self::encodeObject($data);
            case 'string':
                return self::encodeString($data);
            case 'integer':
                return self::encodeInteger($data);
            case 'boolean':
                return self::encodeBoolean($data);
            case 'double':
                return self::encodeDouble($data);
            case 'NULL':
                return self::encodeNull($data);
            case 'resource':
                // TODO
                break;
            default:
                throw new UnencodeableException('Contains unencodeable type', 3);
        }
    }
1288235
public static function encode($data)
    {
        if (is_object($data)) {
            if (method_exists($data, "toArray")) {
                $data = $data->toArray();
            } else {
                $data = (array) $data;
            }
        }

        $encoder = new self($data);
        $encoded = $encoder->doEncode();

        return $encoded;
    }
137826
function encode($data): string {
        try {
            return $this->etf->encode($data);
        } catch (\CharlotteDunois\Kimberly\Exception $e) {
            throw new \CharlotteDunois\Yasmin\WebSocket\DiscordGatewayException('The ETF encoder was unable to encode the data', 0, $e);
        }
    }
45560
function encode(data) {
  var encodedData = null;
  try {
    encodedData = JSON.stringify(data);
  } catch (err) {
    logger.warn('failed encoding data', data);
  }
  return encodedData;
}
1283318
public function encrypt($data) {
        if (is_array($data)) return array_map([$this, __FUNCTION__], $data);
        openssl_private_encrypt($data, $result, $this->key);
        return base64_encode($result);
    }
949763
private function encrypt($data)
	{
		$key = $this->_config['appSecret'];
		// encrypt
		$key    =   md5($key);
	    $x      =   0;
	    $len    =   strlen($data);
	    $l      =   strlen($key);
	    for ($i = 0; $i < $len; $i++)
	    {
	        if ($x == $l) 
	        {
	            $x = 0;
	        }
	        $char .= $key{$x};
	        $x++;
	    }
	    for ($i = 0; $i < $len; $i++)
	    {
	        $str .= chr(ord($data{$i}) + (ord($char{$i})) % 256);
	    }
	    return base64_encode($str);
	}
830265
private function htmlEncode($data)
    {
        if (empty($data)) {
            return null;
        }

        $safeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-";

        $result = "";
        for ($i = 0; $i < strlen($data); $i++) {
            if (strstr($safeChars, $data[$i])) {
                $result .= $data[$i];
            } else if ("7F" >= $var = bin2hex(substr($data, $i, 1))) {
                $result .= "&#x" . $var . ";";
            } else {
                $result .= $data[$i];
            }
        }

        return $result;
    }