对密文进行加密
@method encrypt
@since 0.0.1
@param {string} $text 需要加密的明文
@return {string}
187056
private function encrypt($text) {
		if(!$this->key) {
			$this->key = base64_decode($this->manager->app->aeskey . '=');
		}

		//获得16位随机字符串，填充到明文之前
		$random = $this->manager->generateRandomString(16);
		$text = $random . pack("N", strlen($text)) . $text . $this->manager->app->appid;

		//网络字节序
		$size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
		$module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
		$iv = substr($this->key, 0, 16);

		//使用自定义的填充方式对明文进行补位填充
		$text = $this->encode($text);
		mcrypt_generic_init($module, $this->key, $iv);

		//加密
		$encrypted = mcrypt_generic($module, $text);
		mcrypt_generic_deinit($module);
		mcrypt_module_close($module);

		//使用BASE64对加密后的字符串进行编码
		return base64_encode($encrypted);
	}
905954
public static function decodeOctal($text)
    {
        $parts = preg_split('/(\\\\\d{3})/s', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
        $text  = '';

        foreach ($parts as $part) {
            if (preg_match('/^\\\\\d{3}$/', $part)) {
                $text .= chr(octdec(trim($part, '\\')));
            } else {
                $text .= $part;
            }
        }

        return $text;
    }
676858
def encrypt_text(self, text, *args, **kwargs):
        
        b = text.encode("utf-8")
        token = self.encrypt(b, *args, **kwargs)
        return base64.b64encode(token).decode("utf-8")
370296
public function decrypt($text, $key)
    {
        $ivSize = mcrypt_enc_get_block_size($this->_mcrypt);

        if (strlen($text) < $ivSize * 3) {
            throw new CryptException('encrypted data is too short.');
        }

        $encryptKey = md5($key, true);

        mcrypt_generic_init($this->_mcrypt, $encryptKey, substr($text, 0, $ivSize));

        $decrypted = mdecrypt_generic($this->_mcrypt, substr($text, $ivSize));
        $length = unpack('N', $decrypted)[1];

        if ($length < 16 || 4 + $length > strlen($decrypted)) {
            throw new CryptException('decrypted data length is too short.');
        }

        $decrypted = substr($decrypted, 4, $length);
        $plainText = substr($decrypted, 0, -16);

        if (md5($plainText, true) !== substr($decrypted, -16)) {
            throw new CryptException('decrypted md5 is not valid.');
        }

        return $plainText;
    }
640725
public function encrypt($clearText) {
    return base64_encode(
                         mcrypt_encrypt(MCRYPT_RIJNDAEL_256,
                                        $this->password,
                                        $clearText,
                                        MCRYPT_MODE_ECB,
                                        mcrypt_create_iv(
                                                         mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB),
                                                         MCRYPT_RAND
                                                        )
                                       )
                        );
  }
254786
public function encrypt($text, $appid)
    {
        try {
            // 获得16位随机字符串，填充到明文之前
            $random = $this->getRandomStr();
            $text = $random . pack("N", strlen($text)) . $text . $appid;
            // 网络字节序
            $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
            $module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
            $iv = substr($this->key, 0, 16);
            // 使用自定义的填充方式对明文进行补位填充
            $pkc_encoder = new PKCS7Encoder();
            $text = $pkc_encoder->encode($text);
            mcrypt_generic_init($module, $this->key, $iv);
            // 加密
            $encrypted = mcrypt_generic($module, $text);
            mcrypt_generic_deinit($module);
            mcrypt_module_close($module);
            
            // print(base64_encode($encrypted));
            // 使用BASE64对加密后的字符串进行编码
            return array(
                ErrorCode::$OK,
                base64_encode($encrypted)
            );
        } catch (\Exception $e) {
            // print $e;
            return array(
                ErrorCode::$EncryptAESError,
                null
            );
        }
    }
14842
public static function encrypt($text, $key, $algo = MCRYPT_RIJNDAEL_256, $mode = MCRYPT_MODE_CBC)
        {
            // Create IV for encryption
            $iv = mcrypt_create_iv(
                mcrypt_get_iv_size(
                    $algo,
                    $mode
                ),
                MCRYPT_RAND
            );

            // Encrypt text and append IV so it can be decrypted later
            $text = mcrypt_encrypt(
                $algo,
                hash('sha256', $key, true),
                $text,
                $mode,
                $iv
            ) . $iv;

            // Prefix text with HMAC so that IV cannot be changed
            return hash(
                'sha256',
                $key . $text
            ) . $text;
        }
989200
protected function pkcs7Decode($text)
    {
        $pad = ord(substr($text, -1));
        if ($pad < 1 || $pad > 32) {
            $pad = 0;
        }
        return substr($text, 0, (strlen($text) - $pad));
    }
133937
protected function encrypt($text): string
    {
        $length = strlen($text);
        $plain = '';
        for ($iteration = 0; $iteration < $length; $iteration += 8) {
            $lBlock = $this->asc2int(substr($text, $iteration, 4));
            $rBlock = $this->asc2int(substr($text, $iteration + 4, 4));
            list($lBlock, $rBlock) = $this->bfEncrypt($lBlock, $rBlock);
            $plain .= $this->int2asc($lBlock) . $this->int2asc($rBlock);
        }
        return $plain;
    }
310209
function _crypt($text, $mode)
    {
        if ( CRYPT_RC4_MODE == CRYPT_RC4_MODE_MCRYPT ) {
            $keyStream = $mode == CRYPT_RC4_ENCRYPT ? 'encryptStream' : 'decryptStream';

            if ($this->$keyStream === false) {
                $this->$keyStream = mcrypt_module_open($this->mode, '', MCRYPT_MODE_STREAM, '');
                mcrypt_generic_init($this->$keyStream, $this->key, '');
            } else if (!$this->continuousBuffer) {
                mcrypt_generic_init($this->$keyStream, $this->key, '');
            }
            $newText = mcrypt_generic($this->$keyStream, $text);
            if (!$this->continuousBuffer) {
                mcrypt_generic_deinit($this->$keyStream);
            }

            return $newText;
        }

        if ($this->encryptStream === false) {
            $this->setKey($this->key);
        }

        switch ($mode) {
            case CRYPT_RC4_ENCRYPT:
                $keyStream = $this->encryptStream;
                list($i, $j) = $this->encryptIndex;
                break;
            case CRYPT_RC4_DECRYPT:
                $keyStream = $this->decryptStream;
                list($i, $j) = $this->decryptIndex;
        }

        $newText = '';
        for ($k = 0; $k < strlen($text); $k++) {
            $i = ($i + 1) & 255;
            $j = ($j + $keyStream[$i]) & 255;
            $temp = $keyStream[$i];
            $keyStream[$i] = $keyStream[$j];
            $keyStream[$j] = $temp;
            $temp = $keyStream[($keyStream[$i] + $keyStream[$j]) & 255];
            $newText.= chr(ord($text[$k]) ^ $temp);
        }

        if ($this->continuousBuffer) {
            switch ($mode) {
                case CRYPT_RC4_ENCRYPT:
                    $this->encryptStream = $keyStream;
                    $this->encryptIndex = array($i, $j);
                    break;
                case CRYPT_RC4_DECRYPT:
                    $this->decryptStream = $keyStream;
                    $this->decryptIndex = array($i, $j);
            }
        }

        return $newText;
    }
593237
public function write(&$text)
    {
        $text = str_replace(
            array_keys($this->_alias_write),
            array_values($this->_alias_write),
            $text);

        return $this;
    }
200630
public function unserialize($text)
    {
        $lines = explode("\n", $text);
        foreach ($lines as $line) {
            $data = explode(':', $line);
            if (count($data) < 2) {
                continue;
            }
            $key = trim($data[0]);
            if (isset($data[1]) && (strlen($data[1]) > 0)) {
                $value = trim($data[1]);
            } else {
                $value = '?';
            }
            if (strcasecmp($key, 'set') === 0) {
                $data = explode('=', $value);
                $key = trim($data[0]);
                if (isset($data[1]) && (strlen($data[1]) > 0)) {
                    $value = trim($data[1]);
                } else {
                    $value = '?';
                }
                $this->setVariable($key, $value);
            } else {
                $this->setParameter($key, $value);
            }
        }
    }
815824
public function setText($text)
    {
        $this->text = $text;
        $this->encodeManager->setData($text);

        return $this;
    }
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;
    }
1078982
public function encrypt($text, $appid)
    {
        try {
            $random = $this->getRandomStr();
            $iv = substr($this->key, 0, 16);
            $pkcEncoder = new PKCS7Encoder();
            $text = $pkcEncoder->encode($random . pack("N", strlen($text)) . $text . $appid);
            $encrypted = openssl_encrypt($text, 'AES-256-CBC', substr($this->key, 0, 32), OPENSSL_ZERO_PADDING, $iv);
            return [ErrorCode::$OK, $encrypted];
        } catch (Exception $e) {
            return [ErrorCode::$EncryptAESError, null];
        }
    }
171851
def encrypt(text):
    ''
    crypt = EncryptionAlgorithm.new(_get_encryption_key())
    return crypt.encrypt(to_blocksize(text))
555756
public function encrypt($text, $appid)
	{

		try {
			//获得16位随机字符串，填充到明文之前
			$random = $this->getRandomStr();
			$text = $random . pack("N", strlen($text)) . $text . $appid;
			// 网络字节序
			$module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
			$iv = substr($this->key, 0, 16);
			//使用自定义的填充方式对明文进行补位填充
			$pkc_encoder = new Pkcs7Encoder;
			$text = $pkc_encoder->encode($text);
			mcrypt_generic_init($module, $this->key, $iv);
			//加密
			$encrypted = mcrypt_generic($module, $text);
			mcrypt_generic_deinit($module);
			mcrypt_module_close($module);

			//使用BASE64对加密后的字符串进行编码
			return base64_encode($encrypted);
		} catch (\Exception $e) {
			@error_log('Encrypt AES Error: ' . $e->getMessage(), 0);
			return FALSE;
		}
	}