encrypt by key.

@param string|array $data: decrypt data reference.
194485
public function decrypt($data) {
        if (is_array($data)) return array_map([$this, __FUNCTION__], $data);
        $raw = base64_decode($data);
        openssl_public_decrypt($raw, $result, $this->key);
        return $result;
    }
748867
public static function Decrypt ($data, $key, $options = []) {
		$options = static::_AdjustOptions($options);
		return openssl_decrypt($data, $options['method'], $key, $options['openssl_options'], $options['iv']);
	}
409779
public function encrypt($data)
    {
        $iv = openssl_random_pseudo_bytes($this->getSize());

        $value = openssl_encrypt(serialize($data), $this->method, $this->key, 0, $iv);

        $mac = $this->hash($iv = base64_encode($iv), $value);

        return base64_encode(json_encode(compact('iv', 'value', 'mac')));
    }
641223
public function decrypt($data, $key = null, $nonce = null)
    {
        $plain = parent::decrypt($data, $key, $nonce);

        $key = (string) $key;
        $nonce = (string) $nonce;

        $this->memzero($data);
        $this->memzero($key);
        $this->memzero($nonce);

        return $plain;
    }
161261
public function decrypt($data, $key = null, $iv = null)
    {
        include_once __DIR__ . '/../lib/aes.class.php';

        return \AesCtr::decrypt(base64_decode($data), $key, $this->keyLength);
    }
1167789
protected function initBufferNoEncryption($data)
    {
        $data   = (binary) $data;
        $header = $this->buildHeader();

        $buffer = new Buffer(strlen((string) $header) + strlen($data));
        $buffer->write((string) $header, 0);
        $buffer->write($data, 12);

        $this->buffer = $buffer;
    }
123081
protected function encrypt($data, $key)
    {
        $iv = random_bytes(16); // AES block size in CBC mode
        // Encryption
        $ciphertext = openssl_encrypt(
            $data,
            'AES-256-CBC',
            mb_substr($key, 0, 32, '8bit'),
            OPENSSL_RAW_DATA,
            $iv
        );
        // Authentication
        $hmac = hash_hmac(
            'SHA256',
            $iv . $ciphertext,
            mb_substr($key, 32, null, '8bit'),
            true
        );
        return $hmac . $iv . $ciphertext;
    }
154077
public  function decryptByPublicKey($data) {
		$pu_key =  openssl_pkey_get_public($this->pubkey);
		$decrypted = "";
		$data = self::urlsafe_b64decode($data);

		openssl_public_decrypt($data,$decrypted,$pu_key);//公钥解密

		return $decrypted;
	}
833135
public function decrypt($data, $key) {

    /* Decode the JSON string */
    $data = json_decode($data, true);

    $dataStructure = array(
      'algo'  => true,
      'mode'  => true,
      'iv'    => true,
      'cdata' => true,
      'mac'   => true,
    );

    if($data === NULL || $this->psl->arrayCheck($data, $dataStructure, false) !== true) {
      throw new \phpSec\Exception\GeneralSecurityException('Invalid data passed to decrypt()');
      return false;
    }
    /* Everything looks good so far. Let's continue.*/
    $td = mcrypt_module_open($data['algo'], '', $data['mode'], '');
    $block = mcrypt_enc_get_block_size($td);

    /* Using PBKDF with constant salts dedicated to each purpose 
     * can securely derivce two keys from one */
    $keySize = strlen($key);
    $key1 = $this->pbkdf2($key, "encrypt", 1, $keySize);
    $key2 = $this->pbkdf2($key, "HMAC", 1, $keySize);

    /* Check MAC. */
    if(base64_decode($data['mac']) != $this->pbkdf2($data['cdata'], $key2, 1, 32)) {
      throw new \phpSec\Exception\GeneralSecurityException('Message authentication code invalid');
      return false;
    }

    /* Init mcrypt. */
    mcrypt_generic_init($td, $key1, base64_decode($data['iv']));

    $decrypted = rtrim(mdecrypt_generic($td, base64_decode($this->stripPadding($block, $data['cdata']))));

    /* Close up. */
    mcrypt_generic_deinit($td);
    mcrypt_module_close($td);

    /*Return decrypted data. */
    return unserialize($decrypted);

  }
429823
public byte[] decrypt(String data, KeyType keyType) {
		return decrypt(SecureUtil.decode(data), keyType);
	}
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;
	}
1029911
public function encrypt($data)
    {
        // Get module
        $module = mcrypt_module_open($this->cipher, '', $this->mode, '');

        // Create initialization vector
        $vector = mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_DEV_URANDOM);

        // Validate key length
        $this->validateKeyLength($this->key, $module);

        // Initialize encryption
        $initResult = mcrypt_generic_init($module, $this->key, $vector);

        if (!is_null($initResult)) {
            $this->throwInitError($initResult, 'encrypt');
        }

        // Encrypt
        $encryptedData = mcrypt_generic($module, $data);

        // Deinitialize encryption
        mcrypt_generic_deinit($module);

        // Ensure integrity of encrypted data with HMAC hash
        $hmac = $this->getHmac($encryptedData);

        return implode('|', array(base64_encode($vector), base64_encode($encryptedData), $hmac));
    }
1371219
public static function decrypt($data) : string {
      $crypter = new Crypter();

      return $crypter->decrypt($data, self::getAppKey());
    }
163250
public function encrypt($data)
    {
        try {
            return openssl_encrypt($data, self::$algorithm, self::$pass);
        } catch (\Exception $e) {
            return $data;
        }
    }
1035660
protected function decrypt($data)
    {
        $data = base64_decode($data);
        $salt = substr($data, 0, 16);
        $data = substr($data, 16);

        $salted = hash('sha512', $this->key . $salt, true);
        $key    = substr($salted, 0, 32);
        $iv     = substr($salted, 32, 16);

        return openssl_decrypt($data, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
    }
669122
public function decrypt($data, $key) : string {
      $this->validateData($data);
      $this->validateKey($key);
     
      if (empty($data)) {
          return '';
      }
 
      list($encrypted, $iv) = explode(self::ENCRYPTED_IV_SEPERATOR, base64_decode($data), 2);

      return openssl_decrypt($encrypted, self::CIPHER_METHOD, $key, 0, $iv);
    }
910024
public function encrypt($data)
    {
        if (!$this->iv || $this->autoIvUpdate) {
            $this->generateIv();
        }

        $output = openssl_encrypt($data, $this->cipher, $this->secret, OPENSSL_RAW_DATA, $this->iv);

        if ($this->formatter) {
            $output = $this->formatter->format($this->iv, $output);
        }

        return $output;
    }