Encrypt and decrypt a string using the Blowfish algorithm with CBC mode.

@param string $string
@param string $key
@param int $operation
@return string
166818
public static function blowfish($string, $key, $operation = self::ENCRYPT) {
        if ($operation === static::ENCRYPT) {
            return static::encrypt($string, $key, static::BLOWFISH);
        } else {
            return static::decrypt($string, $key, static::BLOWFISH);
        }
    }
849730
static function lock($string, $key = null) {
        return openssl_encrypt($string, self::_getSecMethod(), Utils::spare($key, self::_geteSecKey()), false, self::_getSecIv());
    }
871491
protected function decrypt($string, $key){
        return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
    }
221663
public static String mix(String string, int key) {
        return ascii(JavaEncrypt.base64(xor(string, key)), key);
    }
1090795
public function encrypt($string, $key = null, $iv = null)
    {
        $key = $key ?: $this->getKey();
        $iv = $iv ?: $this->getIv();

        return $this->cipher->encrypt($string, $key, $iv);
    }
309569
public static function decrypt($data, $key) {

        static :: check();

        $hmac       = mb_substr($data, 0, 32, self :: ENCODING);
        $iv         = mb_substr($data, 32, 16, self :: ENCODING);
        $ciphertext = mb_substr($data, 48, null, self :: ENCODING);

        //Authentication
        $hmacNew = hash_hmac(self :: ALGORITHM, $iv . $ciphertext, mb_substr($key, 32, null, self :: ENCODING), true);

        if(true === static :: hash_equals($hmac, $hmacNew)) {
            return openssl_decrypt($ciphertext, self :: METHOD, mb_substr($key, 0, 32, self :: ENCODING), OPENSSL_RAW_DATA, $iv);
        }

        return null;
    }
370610
public static function decrypt(string $data, string $secret='', string $algorithm='AES-256-CBC')
  {
    # if AES we extract the 16 bytes in the beginning as the IV
    if ( strtoupper(substr($algorithm,0,3))==='AES' ) {
      $encoded  = base64_decode($data);
      $iv       = substr($encoded,0,16);
      $encoded  = substr($encoded,16);
    } else {
      $encoded = $data;
      $iv = '';
    }

    # If no secret provided, use the one in config
    if (empty($secret))
      $secret = config()->get('application.secret');

    # Decrypt
    $result = openssl_decrypt($encoded,$algorithm,$secret,0,$iv);

    return $result;
  }
883328
private static function decryptOpenSSl(
        $key,
        $crypt_text,
        $method,
        $iv
    ) {
        /**
         * ------------------------------------
         * Doing decryption
         * ------------------------------------
         */
        $chipper = openssl_get_cipher_methods();
        if (!is_string($method) || !in_array($method, $chipper)) {
            $method = self::DEFAULT_CHIPPER;
        }

        return @openssl_decrypt($crypt_text, $method, $key, 0, $iv);
    }
277375
protected function encrypt($key, $text)
    {
        $size = mcrypt_get_block_size('blowfish', 'ecb');
        $input = $this->pkcs5_pad($text, $size);
        $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 = mcrypt_generic($td, $input);
        mcrypt_generic_deinit($td);
        mcrypt_module_close($td);

        return bin2hex($data);
    }
1313432
static function Encrypt($data, $key, $encode = true)
	{
		McryptUtil::Init();
		
		$encrypted = mcrypt_encrypt(McryptUtil::$CIPHER, $key, $data, McryptUtil::$MODE, McryptUtil::$IV);
		
		return ($encode) ? base64_encode($encrypted) : $encrypted;
	}
904545
public function encrypt($data, $key) {
        if ($data === '') {
            return $data;
        }

        $cipher = $this->createCipher($key);

        $encrypted = mcrypt_generic($cipher, $data);

        $this->clearCipher($cipher);

        return $encrypted;
    }
654837
public function encryptString($algo, $string, $key = null)
    {     
        if (!empty($algo) && !empty($string)) {   
            if ($key == null) {
                $ctx = hash_init($algo);
            } else {
                $ctx = hash_init($algo, HASH_HMAC, $key);
                hash_update($ctx, $string);
            }
            return hash_final($ctx);
        }
        return false;
    }
994489
protected function doDecrypt($data, $key, $iv)
    {
        return openssl_decrypt($data, $this->getMethod(), $key, OPENSSL_RAW_DATA, $iv);
    }
545245
public function decrypt($crypttext, $key = null) {
        if(null !== $key) {
            $this->_key = md5($key);
        }

        $crypttext = base64_decode($crypttext);
        $plaintext = '';
        $td        = mcrypt_module_open($this->_cypher, '', self::MODE, '');
        $ivsize    = mcrypt_enc_get_iv_size($td);
        $iv        = substr($crypttext, 0, $ivsize);
        $crypttext = substr($crypttext, $ivsize);
        if ($iv) {
            mcrypt_generic_init($td, $this->_key, $iv);
            $plaintext = mdecrypt_generic($td, $crypttext);
        }
        return trim($plaintext);
    }
169470
public static function decrypt($str, $key) {
        if ($str == "") {
            return "";
        }
        $data   =    self::_des($key,$str,0);
        $expire = substr($data,0,10);
        if($expire > 0 && $expire < time()) {
            return '';
        }
        $data   = substr($data,10);
        return $data;
    }
1044983
public static function encrypt(string $text, string $key, string $iv, int $option = OPENSSL_RAW_DATA): string
    {
        self::validateKey($key);
        self::validateIv($iv);

        return openssl_encrypt($text, self::getMode($key), $key, $option, $iv);
    }
387705
public function bitOp($operation, $destination, $key, ...$keys) {
        return $this->send(array_merge(['bitop', $operation, $destination], (array) $key, $keys));
    }