Encode data inside a random string.

@param string $data : the data to encode

@return string : the encoded data
333983
private function encode($data)
    {
        $rdm = $this->random();
        $data = base64_encode($data);
        $startIndex = rand(1, strlen($rdm));
        $params = base64_encode($startIndex).self::ENC_SEPARATOR;
        $params .= base64_encode(strlen($data)).self::ENC_SEPARATOR;

        return $params.substr_replace($rdm, $data, $startIndex, 0);
    }
416124
public function encode(string $data): string
    {
        $data = str_split($data);
        $data = array_map("ord", $data);

        $leadingZeroes = 0;
        while (!empty($data) && 0 === $data[0]) {
            $leadingZeroes++;
            array_shift($data);
        }
        $converted = $this->baseConvert($data, 256, 62);
        if (0 < $leadingZeroes) {
            $converted = array_merge(
                array_fill(0, $leadingZeroes, 0),
                $converted
            );
        }
        return implode("", array_map(function ($index) {
            return $this->options["characters"][$index];
        }, $converted));
    }
21517
private function encrypt(string $data): string
    {
        $cipher = Cryptography::encrypt($data, $this->cryptKey);
        list($initializationVector, $cipher) = explode(':', $cipher);
        $initializationVector = base64_decode($initializationVector);
        $cipher = base64_decode($cipher);
        $content = $initializationVector . Cryptography::getEncryptionAlgorithm() . $cipher;
        $hmac = hash_hmac('sha256', $content, $this->cryptAuth);
        return $hmac . ':' . base64_encode($initializationVector) . ':' . base64_encode($cipher);
    }
1081834
public function crypt(string $data) {
        $keyHash = md5(Config::getConfig()->encrypt->key);
        $key = substr($keyHash, 0, mcrypt_get_key_size(self::$cipher, self::$mode));
        $iv = substr($keyHash, 0, mcrypt_get_block_size(self::$cipher, self::$mode));
        return base64_encode(mcrypt_encrypt(self::$cipher, $key, $data, self::$mode, $iv));
    }
1229801
public static function encode($data, array $context = [])
    {
        $context = array_merge(static::$defaultEncodeContext, $context);

        return static::encodeData($data, $context);
    }
84186
public function encode($data)
    {
        return openssl_encrypt($data, $this->method, $this->key, 0, $this->iv);
    }
220788
public static function encode(/*mixed*/ $data) {
    $json = json_encode($data, JSON_UNESCAPED_SLASHES);

    // Turn some special characters into their JSON representation.
    $json = str_replace(["\t", "\r", "\n"], ['\\t', '\\r', '\\n'], $json);

    return $json;
  }
113523
public function encodeUtf8($data)
    {
        if ($data === null || $data === '') {
            return $data;
        }
        if (is_array($data)) {
            foreach ($data as $key => $value) {
                $data[$key] = $this->encodeUtf8($value);
            }

            return $data;
        } else {
            if (!mb_check_encoding($data, 'UTF-8')) {
                return mb_convert_encoding($data, 'UTF-8');
            }

            return $data;
        }
    }
183892
protected function encode($data)
    {
        if ($this->getEncoding() === self::ENCODING_BASE64) {
            return base64_encode(serialize($data));
        } else {
            return serialize($data);
        }
    }
1055413
public static function encodeUrlSafe($data) {
		$encoded = self::encode($data);

		return \strtr(
			$encoded,
			self::LAST_THREE_STANDARD,
			self::LAST_THREE_URL_SAFE
		);
	}
220785
public static function encodePhp( array $data ) {
		$ret = '';
		foreach ( $data as $key => $value ) {
			if ( strcmp( $key, intval( $key ) ) === 0 ) {
				self::$logger->warning( "Ignoring unsupported integer key \"$key\"" );
				continue;
			}
			if ( strcspn( $key, '|!' ) !== strlen( $key ) ) {
				self::$logger->error( "Serialization failed: Key with unsupported characters \"$key\"" );
				return null;
			}
			$v = self::serializeValue( $value );
			if ( $v === null ) {
				return null;
			}
			$ret .= "$key|$v";
		}
		return $ret;
	}
813594
private function encodeString($data = null)
    {
        $data = is_null($data) ? $this->data : $data;
        return sprintf("%d:%s", strlen($data), $data);
    }
545778
static public function encode($data)
	{
	    if (is_string($data)) {
	        $data = str_replace(array("\r\n"), "", $data);
	        if (strpos($data, '{') ===0 || strpos($data, '[') ===0) {
	            $data = json_decode($data, true);
	        }
	    }
	    
		return json_encode($data);
	}
528809
protected function convertEncoding($data)
    {
        if ($this->getEncodingInput() == $this->getEncodingOutput()) {
            return $data;
        }

        if (is_null($data)) {
            return $data;
        }

        if (is_array($data)) {
            foreach ($data as $key => $value) {
                $data[$key] = $this->convertEncoding($value);
            }

            return $data;
        }

        if ($this->getEncodingOutput() == 'UTF-8') {
            return utf8_encode($data);
        }

        return utf8_decode($data);
    }
289559
public function encode($data): string
    {
        $encoded = \json_encode($data, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
        if (\json_last_error() !== JSON_ERROR_NONE) {
            throw new EncodingException(\json_last_error_msg());
        }
        return $encoded;
    }
1164711
public static function decode($data)
    {
        if (!is_string($data)) {
            throw new InvalidArgumentException('data must be string');
        }
        if (1 === strlen($data) % 4) {
            throw new InvalidArgumentException('invalid base64 string length');
        }
        $result = base64_decode($data, true);
        if (false === $result) {
            throw new InvalidArgumentException('invalid base64 string');
        }

        return $result;
    }
32494
private function safe_encode($data) {
    if (is_array($data)) {
      return array_map(array($this, 'safe_encode'), $data);
    } else if (is_scalar($data)) {
      return str_ireplace(
        array('+', '%7E'),
        array(' ', '~'),
        rawurlencode($data)
      );
    } else {
      return '';
    }
  }