Decrypt a serialized value

@param string $value
@param string $key
@param boolean $base64 Whether to base64 decode the value before decrypting
@return mixed
2052
public function decrypt(string $value, string $key, bool $base64 = false)
    {
        if ($base64) {
            $value = base64_decode($value);
        }
        $ret = $this->decryptBinary($value, $key);
        return unserialize($ret);
    }
978382
public static function decrypt($message, $key, $encoded = false)
    {
        if ($encoded) {
            $message = base64_decode($message, true);
            if ($message === false) {
                throw new Exception('Encryption failure');
            }
        }

        $nonceSize = openssl_cipher_iv_length(self::METHOD);
        $nonce = mb_substr($message, 0, $nonceSize, '8bit');
        $ciphertext = mb_substr($message, $nonceSize, null, '8bit');

        $plaintext = openssl_decrypt(
            $ciphertext,
            self::METHOD,
            $key,
            OPENSSL_RAW_DATA,
            $nonce
        );

        return $plaintext;
    }
1349002
def decrypt(self, value):
        """"""
        try:
            value, timestamp, signature = value.split("|")
        except ValueError:
            return None
        if check_signature(signature, self.secret, value + timestamp, encoding=self.encoding):
            return base64.b64decode(value).decode(self.encoding)
681323
public function get($key, $default = null)
    {
        $value = Arr::get($_COOKIE, $key);

        if ($value === null) {
            return $default;
        }

        return $this->defaults['encrypt']
            ? $this->getEncryption()->decryptBase64($value)
            : $value;
    }
1332533
public String decrypt(String encrypted) throws Exception {

        byte[] decodedValue = Base64Coder.decode(encrypted.toCharArray());

        Cipher c = getCipher(Cipher.DECRYPT_MODE);
        byte[] decValue = c.doFinal(decodedValue);

        return new String(decValue);
    }
371657
public static function decrypt($data,$key){
        if(empty(self::$handler)){
            self::init();
        }
        $class  =   self::$handler;         
        return $class::decrypt($data,$key);
    }
552219
public function decode($value)
    {


        $prepareForDecrypt = @unserialize(base64_decode(urldecode($value)));
        $preparedIv = base64_decode($prepareForDecrypt['iv']);
        $preparedKey = base64_decode($prepareForDecrypt['key']);

        $value = base64_decode($prepareForDecrypt['value']);

        if (false !== $decypted = @mcrypt_decrypt($this->algorithm, $preparedKey, $value, $this->mode, $preparedIv)) {
            return trim($decypted, "\0\4");
        }

        return false;
    }
50503
public function decrypt($string){
        $string = explode('|', $string.'|');
        $decoded = base64_decode($string[0]);
        $iv = base64_decode($string[1]);
        if(strlen($iv)!==mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC))
            return false;
        $key = pack('H*', $this->key);
        $decrypted = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $decoded, MCRYPT_MODE_CBC, $iv));
        $mac = substr($decrypted, -64);
        $decrypted = substr($decrypted, 0, -64);
        $calcmac = hash_hmac('sha256', $decrypted, substr(bin2hex($key), -32));
        if($calcmac!==$mac)
            return false;
        return unserialize($decrypted);
    }
410293
public static function decrypt($value)
        {
            $value      = base64_decode($value);
            // To decrypt the value, we first need to extract the input vector and
            // the encrypted value. The input vector size varies across different
            // encryption ciphers and modes, so we'll get the correct size.

            $iv         = substr($value, 0, static::iv_size());
            $value      = substr($value, static::iv_size());
            // Once we have the input vector and the value, we can give them both
            // to Mcrypt for decryption. The value is sometimes padded with \0,
            // so we will trim all of the padding characters.

            $key        = static::key();
            $value      = mcrypt_decrypt(static::$cipher, $key, $value, static::$mode, $iv);
            return static::unpad($value);
        }
783659
public function base64($value, array $options, $mode) {
        if ($mode === self::TO && $options['encode']) {
            return base64_encode($value);
        }

        if ($mode === self::FROM && $options['decode']) {
            return base64_decode($value);
        }

        return $value;
    }
695779
public static String decryptData(String base64Data, String key) throws Exception {
		Cipher cipher = Cipher.getInstance(ALGORITHM_MODE_PADDING);
		cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(HashKit.md5(key).toLowerCase().getBytes(), ALGORITHM));
		return new String(cipher.doFinal(Base64Kit.decode(base64Data)));
	}
220875
public function decr($key, $value = 1) {
        $value = (int) $value;
        try {
            $result = ($value > 1)
                ? $this->getRedis()->decrBy($key, $value)
                : $this->getRedis()->decr($key);
            if ($result !== false) {
                return $result;
            }
            throw new ImpossibleValueException();
        } catch (RedisException $ex) {
            throw new ConnectException();
        }
    }
775511
public function decrypt($string, $key)
    {
        $key = $this->_formKey($key, $string);

        $string = substr($string, 3);
        $string = str_replace('!', '=', $string);
        $string = base64_decode($string);
        $string = $string ^ $key;

        return substr($string, 2, -2);
    }
236679
public function decrypt($string, $key = null)
    {
        if (null === $key) {
            $key = $this->getEncryptKey();
        }

        $cipherText = base64_decode($string);
        $ivSize     = $this->getMsCryptIvSize();

        $ivDec = substr($cipherText, 0, $ivSize);

        $cipherText = substr($cipherText, $ivSize);

        return mcrypt_decrypt(
            $this->getMcryptCipher(),
            $key,
            $cipherText,
            $this->getMcryptMode(),
            $ivDec
        );
    }
1174969
public function encode($value)
    {
        $encryptedValue = $this->getEncryptor()->encrypt($value);
        $encodedValue = base64_encode($encryptedValue);

        return $encodedValue;
    }
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);

  }
49873
public function decode($encodedValue)
    {
        $encryptedValue = base64_decode($encodedValue);
        $value = $this->getEncryptor()->decrypt($encryptedValue);

        return $value;
    }