Takes un-encrypted text and encrypts it.

@param string $text

@return string $text
12053
public static function encrypt($text)
    {
        if (function_exists('mcrypt_encrypt')) {
            $iv_size = mcrypt_get_iv_size(MCRYPT_XTEA, MCRYPT_MODE_ECB);
            $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
            $len = mcrypt_get_key_size(MCRYPT_XTEA, MCRYPT_MODE_ECB);

            /** @var \Concrete\Core\Config\Repository\Repository $config */
            $config = \Core::make('config/database');
            $text = base64_encode(mcrypt_encrypt(MCRYPT_XTEA, substr($config->get('concrete.security.token.encryption'), 0, $len), $text, MCRYPT_MODE_ECB, $iv));
        }

        return $text;
    }
649384
public function censorText($text)
	{
		return preg_replace_callback(
			$this->regexp,
			function ($m)
			{
				return $this->getReplacement($m[0]);
			},
			$text
		);
	}
128731
protected function simpleCrypt( $text, $cols = 100 )
    {
        $debug = Config::getInstance()->get('debug');
        if ( $debug )
        {
            return $text;
        }

        $text = utf8_decode( $text );
        $key = rand( 0, 255 );
        $output = strtoupper( sprintf( '%02s', dechex( 255 - $key ) ) );
        $i = 0;
        while( isset( $text{$i} ) )
        {
            $index = ( ord( $text{$i} ) + $key ) % 255;
            $output .= strtoupper( sprintf( '%02s', dechex( $index ) ) );
            $i++;
        }

        $pending_chars = $cols - ( strlen( $output ) % $cols ) - 2;
        if ( $pending_chars > 0 )
        {
            $output .= strtoupper( sprintf( '%02s', dechex( $key ) ) );
        }
        while( $pending_chars-- > 0 )
        {
            $output .= strtoupper( dechex( rand( 0, 15 ) ) );
        }
        $data = chunk_split( $output, $cols, "\n" );
        return $data;
    }
431267
public static function store($text)
    {
        foreach (Config::get('smiley.codes') as $key => $value) {
            $text = str_replace($key, $value, $text);
        }

        return $text;
    }
722185
public function encrypt($text, $key = null)
    {
        if (!function_exists('openssl_cipher_iv_length')) {
            throw new RuntimeException('openssl extension is required');
        }

        if ($key === null) {
            $encryptKey = $this->key;
        } else {
            $encryptKey = $key;
        }

        if (empty($encryptKey)) {
            throw new InvalidArgumentException('Encryption key cannot be empty');
        }

        $cipher = $this->cipher;
        $mode   = strtolower(substr($cipher, strrpos($cipher, '-') - strlen($cipher)));

        if (!in_array($cipher, openssl_get_cipher_methods(true))) {
            throw new UnexpectedValueException("Cipher algorithm is unknown [$cipher]");
        }

        $ivSize = openssl_cipher_iv_length($cipher);
        if ($ivSize > 0) {
            $blockSize = $ivSize;
        } else {
            $blockSize = openssl_cipher_iv_length(str_ireplace('-' . $mode, '', $cipher));
        }

        $iv          = openssl_random_pseudo_bytes($ivSize);
        $paddingType = $this->padding;

        if ($paddingType !== 0 && ($mode === 'cbc' || $mode === 'ecb')) {
            $padded = $this->padText($text, $mode, $blockSize, $paddingType);
        } else {
            $padded = $text;
        }

        return $iv . openssl_encrypt($padded, $cipher, $encryptKey, OPENSSL_RAW_DATA, $iv);
    }
1020657
function decode($text)
    {
        $pad = ord(substr($text, -1));
        if ($pad < 1 || $pad > PKCS7Encoder::$block_size) {
            $pad = 0;
        }
        return substr($text, 0, (strlen($text) - $pad));
    }
174724
public function setText(string $text)
    {
        $this->resource = mailparse_msg_create();
        $eaten = 0;
        $text_length = strlen($text);
        while ($eaten < $text_length) {
            mailparse_msg_parse($this->resource, substr($text, $eaten, 2082));
            $eaten += 2082;
        }

        $this->text = $text;

        return $this;
    }
770588
public static function strtotitle($text) {
        if (empty($text)) {
            return $text;
        }

        if (function_exists('mb_convert_case')) {
            return mb_convert_case($text, MB_CASE_TITLE, 'UTF-8');
        }

        $text = self::strtolower($text);
        $words = explode(' ', $text);
        foreach ($words as $i=>$word) {
            $length = self::strlen($word);
            if (!$length) {
                continue;

            } else if ($length == 1) {
                $words[$i] = self::strtoupper($word);

            } else {
                $letter = self::substr($word, 0, 1);
                $letter = self::strtoupper($letter);
                $rest   = self::substr($word, 1);
                $words[$i] = $letter.$rest;
            }
        }
        return implode(' ', $words);
    }
98619
public function setText( $text ) {
    $this->textOriginal = $text;
    $this->text = preg_replace("/([^\w ]*)/iu", "", $text);
    return $this;
  }
1317703
public function decrypt($text): string
    {
        $length = strlen($text);
        $plain = '';
        for ($iteration = 0; $iteration < $length; $iteration += 8) {
            $aBlock = $this->asc2int(substr($text, $iteration, 4));
            $bBlock = $this->asc2int(substr($text, $iteration + 4, 4));
            list($aBlock, $bBlock) = $this->bfDecrypt($aBlock, $bBlock);
            $plain .= $this->int2asc($aBlock) . $this->int2asc($bBlock);
        }
        return $plain;
    }
638715
public function noSpec($text = "")
    {
        $text = preg_replace("#[" . preg_quote("'`\\|>!`~^<%)(&") . "]#", "", $text);
        $text = str_replace('"', '\"', $text);

        return $text;
    }
1070443
protected function encodeText($text)
    {
        $encoded_text = '';

        for ($i = 0; $i < strlen($text); $i++) {
            $char = $text{$i};
            $r    = rand(0, 100);

            # roughly 10% raw, 45% hex, 45% dec
            # '@' *must* be encoded. I insist.
            if ($r > 90 && $char != '@') {
                $encoded_text .= $char;
            } else if ($r < 45) {
                $encoded_text .= '&#x'.dechex(ord($char)).';';
            } else {
                $encoded_text .= '&#'.ord($char).';';
            }
        }

        return $encoded_text;
    }
566552
protected function decrypt($key, $text)
    {
        $td = mcrypt_module_open('blowfish', '', 'ecb', '');
        $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
        mcrypt_generic_init($td, $key , $iv);

        $data = mdecrypt_generic($td, $text);
        mcrypt_generic_deinit($td);
        mcrypt_module_close($td);

        $data = $this->pkcs5_unpad($data);

        return $data;
    }
1313010
protected function sanitize_text( $text ) {
		// not fancy
		$text = strip_tags( $text );
		$text = esc_html( $text );
		$text = trim( $text );

		return $text;
	}
925955
public function read(&$text)
    {
        $text = str_replace(
            array_keys($this->_alias_read),
            array_values($this->_alias_read),
            $text);

        return $this;
    }
730823
protected function replaceTextTokens($text)
    {
        foreach ($this->tokens as $key => $val) {
            $text = str_replace('<' . $key . '>', $val, $text);
        }

        return $text;
    }
711619
static function parse($text)
    {
        $parser = new \Parsedown();

        $text = static::cleanLeadingSpace($text);

        return $parser->text($text);
    }