Encrypts $s with this cipher instance method and key.
@param $s A raw string to encrypt.
@return The result as a raw string, or null in case of error.
437160
public function encrypt($s)
	{
		$m = $this->load();
		if($m === null)
			return null;
		$r = mcrypt_generic($m, $this->_padding == parent::PADDING_PKCS7
				? self::addPKCS7Padding($s,
					mcrypt_enc_get_block_size($m))
				: $s);
		$this->unload($m);
		return $r;
	}
849730
static function lock($string, $key = null) {
        return openssl_encrypt($string, self::_getSecMethod(), Utils::spare($key, self::_geteSecKey()), false, self::_getSecIv());
    }
501447
public function decryptResponse($response)
    {
        if (!is_string($response)) {
            return $response;
        }

        if ($this->usesEncryption()) {
            return json_decode(
                json_encode(
                    JWT::decode(
                        $response,
                        $this->encryptionKey,
                        array($this->encryptionAlgorithm)
                    )
                ),
                true
            );
        }

        throw EncryptionConfigurationException::undeterminedEncryption();
    }
612413
public function decrypt($s)
	{
		$m = $this->load();
		if($m === null)
			return null;
		$padded = mdecrypt_generic($m, $s);
		$r = $this->_padding == parent::PADDING_PKCS7
			? self::removePKCS7Padding($padded,
				mcrypt_enc_get_block_size($m))
			: $padded;
		$this->unload($m);
		return $r;
	}
111023
public function decrypt($encrypted, $key)
	{
		if (empty($encrypted))
			return null;

		list($identifier, $input) = explode(self::SEPARATOR_ALGORITHM, $encrypted, 2);

		if ($identifier !== self::IDENTIFIER)
			throw new Exception('Encryption can not be decrypted. Unsupported identifier: ' . $identifier);

		// Split the input into its parts
		$cipherSplit = explode(self::SEPARATOR_CRYPTO_PARTS, $input);
		$originalSize = intval($cipherSplit[0]);
		$iv = cryptoHelpers::toNumbers($cipherSplit[1]);
		$cipherText = $cipherSplit[2];

		// Set up encryption parameters
		$cipherIn = cryptoHelpers::toNumbers($cipherText);
		$keyAsNumbers = cryptoHelpers::toNumbers(bin2hex($key));
		$keyLength = count($keyAsNumbers);

		$decrypted = AES::decrypt(
			$cipherIn,
			$originalSize,
			AES::modeOfOperation_CBC,
			$keyAsNumbers,
			$keyLength,
			$iv
		);

		// Byte-array to text.
		$hexDecrypted = cryptoHelpers::toHex($decrypted);
		$retVal = pack("H*", $hexDecrypted);

		return $retVal;
	}
507253
public function encrypt(string $jws): string
    {
        $headers = $this->getEncryptionHeader();
        $encryptionKey = $this->encryptionKeyset->get($this->encryptionKeyIndex);

        if ($encryptionKey->has('kid')) {
            $headers['kid'] = $encryptionKey->get('kid');
        }

        $jwe = $this->jweBuilder
            ->create()
            ->withPayload($jws)
            ->withSharedProtectedHeader($headers)
            ->addRecipient($encryptionKey)
            ->build();

        $serializer = new JWECompactSerializer(new StandardConverter());

        return $serializer->serialize($jwe, 0);
    }
1360101
protected function encrypt(string $string)
    {
        $pub_key = openssl_pkey_get_public($this->getRsaKey($this->pub_key));

        $length = openssl_pkey_get_details($pub_key)['bits'];

        $string = str_split($string, $length / 8 - 11);
        $encryptedString = '';

        foreach ($string as $value) {
            openssl_public_encrypt($value, $encrypted, $pub_key);
            $encryptedString .= $encrypted;
        }

        return base64_encode($encryptedString);
    }
39286
function encrypt (str) {
    var cipher = crypto.createCipher(algorithm, key)
      , crypted = cipher.update(str, from, to) + cipher.final(to)
    return crypted;
  }
920498
public function encryptByConfig($str)
    {
        if ($this->isSingle()) {
            if ($security_key = $this->getConfigByName('security_key')) {
                $str = $this->encrypt($str, hex2bin(md5($security_key)));
            }
            return $str;
        }
        return '';
    }
566864
public function encrypt($string)
    {
        $string = serialize($string);
        $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), MCRYPT_DEV_URANDOM);
        $key = pack('H*', $this->key);
        $mac = hash_hmac('sha256', $string, substr(bin2hex($key), -32));
        $passcrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string.$mac, MCRYPT_MODE_CBC, $iv);
        return base64_encode($passcrypt).'|'.base64_encode($iv);
    }
849581
protected function decrypt(string $string)
    {
        $pri_key = openssl_pkey_get_private($this->getRsaKey($this->pri_key));

        $length = openssl_pkey_get_details($pri_key)['bits'];

        $splits = str_split(base64_decode($string), $length / 8);

        $decryptedString = '';

        foreach ($splits as $split) {
            openssl_private_decrypt($split, $decrypted, $pri_key);
            $decryptedString .= $decrypted;
        }

        return $decryptedString;
    }
917233
public function encrypt($plaintext, $key = null) {
        if(null !== $key) {
            $this->_key = md5($key);
        }

        $td = mcrypt_module_open($this->_cypher, '', self::MODE, '');
        $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
        mcrypt_generic_init($td, $this->_key, $iv);
        $crypttext = mcrypt_generic($td, $plaintext);
        mcrypt_generic_deinit($td);
        return base64_encode($iv . $crypttext);
    }
514278
final public static Key makeSystem(String s) {
    byte[] kb= decodeKeyName(s);
    byte[] kb2 = new byte[kb.length+1];
    System.arraycopy(kb,0,kb2,1,kb.length);
    kb2[0] = Key.BUILT_IN_KEY;
    return Key.make(kb2);
  }
867211
function _raw_encrypt($m)
    {
        $temp = $this->_os2ip($m);
        $temp = $this->_rsaep($temp);
        return  $this->_i2osp($temp, $this->k);
    }
597764
public static function encrypt($string, $hash = false)
    {
        /**
         * if empty values return null
         */
        if (!$string) {
            return null;
        }
        /**
         * Using Alternative Encryption
         * if mCrypt not loaded
         */
        if (! extension_loaded('mCrypt')) {
            return static::altEncrypt($string, $hash);
        }

        /**
         * ------------------------------------
         * Safe Sanitized hash
         * ------------------------------------
         */
        (is_null($hash) || $hash === false) && $hash = '';
        // safe is use array or object as hash
        $hash      = Util::maybeSerialize($hash);

        /**
         * ------------------------------------
         * Set Key
         * ------------------------------------
         */
        $key       = pack('H*', sha1(sha256::hash($hash)));
        /**
         * pad to 24 length
         * on PHP 5.5 + need keylength 16, 24 or 32
         */
        $key       = str_pad($key, 24, "\0", STR_PAD_RIGHT);

        /**
         * create array as content
         * this is for great opinion that values has already encrypted
         * to easily check values
         */
        $string    = serialize(array('mcb' => $string));

        /**
         * ------------------------------------
         * Doing encryption
         * ------------------------------------
         */
        $iv_size   = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
        $iv        = mcrypt_create_iv($iv_size, MCRYPT_RAND);
        $crypt_text = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_ECB, $iv);

        // freed the memory
        unset($string, $key, $iv);
        // save as bse64 encode safe
        $crypt_text = trim(Util::safeBase64Encode($crypt_text));

        /**
         * ------------------------------------
         * Inject Result of with sign
         * ------------------------------------
         */
        if (strlen($crypt_text) > 10) {
            return substr_replace($crypt_text, '_mCb=', 10, 0);
        } else {
            return substr_replace($crypt_text, '_mCb=', 2, 0);
        }
    }
132712
public function encrypt($str = null, $key = null)
    {
        if (!is_null($key)) {
            $this->setSalt($key);
        }
        srand((double)microtime()*1000000);
        $key_encrypt    = md5(rand(0,32000));
        $count          = 0;
        $tmp            = '';
        for ($ctr=0;$ctr<strlen($str);$ctr++) {
            if ($count==strlen($key_encrypt)) {
                $count=0;
            }
            $tmp.= substr($key_encrypt,$count,1).(substr($str,$ctr,1) ^ substr($key_encrypt,$count,1) );
            $count++;
        }
        return base64_encode(self::getEncryptionKey($tmp));
    }
1090795
public function encrypt($string, $key = null, $iv = null)
    {
        $key = $key ?: $this->getKey();
        $iv = $iv ?: $this->getIv();

        return $this->cipher->encrypt($string, $key, $iv);
    }