Encript data

@param string $data
@return string
163250
public function encrypt($data)
    {
        try {
            return openssl_encrypt($data, self::$algorithm, self::$pass);
        } catch (\Exception $e) {
            return $data;
        }
    }
412559
protected function switchContentType($data)
    {
        switch ($this->format) {
            case 'application/json':
                $data = json_encode(is_object($data) ? (array)$data : $data);
                break;

            case 'application/xml':
                $data = is_object($data) ? (string)$data : $data;
                break;

            default:
                $data = (string)$data;
        }

        return $data;
    }
496380
protected function encodeValue($data)
	{
	    // xml wrap entity_element label
	    if ($this->options['data_format'] == 'xml') {
	        $data = $this->formatter->wrap($data, $this->options['entity_element']);
	    }
	    return $this->formatter->encode($data);
	}
660662
public function xssFunc($data)
    {
        if (!\is_array($data)) {
            return Security::detectXss($data);
        }

        $results = Security::detectXssFromArray($data);
        $results_parts = array_map(function($value, $key) {
            return $key.': \''.$value . '\'';
        }, array_values($results), array_keys($results));

        return implode(', ', $results_parts);
    }
1240560
public function encode($data) : string
    {
        $result = json_encode($data, $this->options, $this->maxDepth);

        $this->checkLastError();

        return $result;
    }
680979
private function serialize($data)
    {
        if ($this->type == 'db') {
            return $this->db->encode($data, $this->packed);
        }

        return $this->packed ? serialize($data) : $data;
    }
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);
        }
    }
733586
protected function getData($data)
    {
        $method = "load" . strtoupper($this->mode);

        libxml_use_internal_errors(true);
        $this->dom->$method($data);
        $this->errors = libxml_get_errors();
        libxml_clear_errors();

        return $data;
    }
101338
public function encrypt($data): string
    {
        if (!$this->password)
        {
            return JSON::encode($data);
        }

        return $this->security()
            ->encrypt(JSON::encode($data));
    }
813594
private function encodeString($data = null)
    {
        $data = is_null($data) ? $this->data : $data;
        return sprintf("%d:%s", strlen($data), $data);
    }
456479
public function serializeData($data) {
		if(is_array($data)) {
			ksort($data);
			$return = '';
			foreach($data as $key => $value) {
				if(is_numeric($key)) {
					$return .= $this->serializeData($value);
				} else {
					$return .= $key . $this->serializeData($value);
				}
			}
			return $return;
		} else {
			return (string)$data;
		}
	}
487834
protected function encodeMessage($data)
    {
        return $this->server->getBean(\Imi\Server\DataParser\DataParser::class)->encode($data);
    }
754169
public function encode($data)
    {

        // Convert the data to a binary string.
        $bits = '';
        foreach (str_split($data) as $char) {
            $bits .= sprintf('%08b', ord($char));
        }

        // Make sure the string length is a multiple of 5, padding if needed.
        $len = strlen($bits);
        $mod = $len % 5;
        if ($mod !== 0) {
            $bits = str_pad($bits, $len + 5 - $mod, '0', STR_PAD_RIGHT);
        }

        // Split the binary string into 5-bit chunks and encode each chunk.
        $output = '';
        foreach (str_split($bits, 5) as $chunk) {
            $output .= substr($this->getConfig('alphabet'), bindec($chunk), 1);
        }

        return $output;

    }
830840
public static function jsonEncode($data)
    {
        $json = json_encode($data);
        // if json_encode failed
        if ($json === false) {
            self::jsonLastError();
        }
        return $json;
    }
580835
public function encode($data): string
    {
        try {
            $data = \serialize($data);
        } catch (\Throwable $exception) {
            throw new SerializationException(
                "The given data cannot be sent because it is not serializable.",
                0,
                $exception
            );
        }

        return \pack("CL", 0, \strlen($data)) . $data;
    }
780600
private function extractScriptDataValue_UI16(&$data)
    {
        $result = $this->parseUI16(substr($data, 0, 2));
        $data = substr($data, 2);

        return $result;
    }
994518
public function jsonEncode($data)
    {
        if (is_array($data)) {
            $ret = "";
            $blWasOne = false;
            $blNumerical = true;
            reset($data);
            while ($blNumerical && $key = key($data)) {
                $blNumerical = !is_string($key);
            }
            if ($blNumerical) {
                return '[' . implode(',', array_map([$this, 'jsonEncode'], $data)) . ']';
            } else {
                foreach ($data as $key => $val) {
                    if ($blWasOne) {
                        $ret .= ',';
                    } else {
                        $blWasOne = true;
                    }
                    $ret .= '"' . addslashes($key) . '":' . $this->jsonEncode($val);
                }

                return "{" . $ret . "}";
            }
        } else {
            return '"' . addcslashes((string) $data, "\r\n\t\"\\") . '"';
        }
    }