@param string $encryptedData

@return string

@throws \InvalidArgumentException
964641
public function decrypt($encryptedData)
    {
        $this->checkClosed();

        //Check encrypted data
        if (!is_string($encryptedData)) {
            throw new \InvalidArgumentException('Encrypted data must be a string');
        }

        //Base64
        if ($this->base64) {
            if ($this->base64UrlSafe) {
                $encryptedData = strtr($encryptedData, self::$BASE64_URL_SAFE_REPLACE[1], self::$BASE64_URL_SAFE_REPLACE[0]);
            }

            $encryptedData = base64_decode($encryptedData, true);

            if ($encryptedData === false) {
                throw new \InvalidArgumentException('Encrypted data is not a valid base64 string');
            }
        }

        //Encryption
        if ($this->randomInitializationVector) {
            $initializationVector = substr($encryptedData, 0, $this->initializationVectorSize);

            if (strlen($initializationVector) < $this->initializationVectorSize) {
                throw new \InvalidArgumentException('Encrypted data is not long enough to get the initialization vector');
            }

            $encryptedData = substr($encryptedData, $this->initializationVectorSize);
        } else {
            $initializationVector = $this->fixedInitializationVector;
        }
        mcrypt_generic_init($this->module, $this->key, $initializationVector);
        $data = mdecrypt_generic($this->module, $encryptedData);
        $data = rtrim($data, "\0");

        return $data;
    }
584300
public static function decode($data)
    {
        if (!is_string($data)) {
            throw new InvalidArgumentException('data must be string');
        }

        // undo the URL safe replacement
        $convertedData = strtr($data, '-_', '+/');

        // restore the padding
        switch (strlen($convertedData) % 4) {
            case 0:
                break;
            case 2:
                $convertedData .= '==';
                break;
            case 3:
                $convertedData .= '=';
                break;
            default:
                throw new InvalidArgumentException('invalid base64url string length');
        }

        return parent::decode($convertedData);
    }
921249
public function getCipherDataSalt($data) {
        if (empty($data)) {
            throw new \Cityware\Exception\InvalidArgumentException('The data to decrypt cannot be empty');
        } else {
            $cipherData = base64_decode($data);
        }
        return substr($cipherData, 0, $this->getSaltSize());
    }
339976
public function decrypt($encrypted, $corpId)
    {
        try {
            $key = $this->getAESKey();
            $ciphertext = base64_decode($encrypted, true);
            $iv = substr($key, 0, 16);

            $decrypted = openssl_decrypt($ciphertext, 'aes-256-cbc', $key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING, $iv);
        } catch (BaseException $e) {
            throw new EncryptionException($e->getMessage(), EncryptionException::ERROR_DECRYPT_AES);
        }

        try {
            $result = $this->decode($decrypted);

            if (strlen($result) < 16) {
                return '';
            }

            $content = substr($result, 16, strlen($result));
            $listLen = unpack('N', substr($content, 0, 4));
            $xmlLen = $listLen[1];
            $xml = substr($content, 4, $xmlLen);
            $fromCorpId = trim(substr($content, $xmlLen + 4));
        } catch (BaseException $e) {
            throw new EncryptionException($e->getMessage(), EncryptionException::ERROR_INVALID_XML);
        }

        if ($fromCorpId !== $corpId) {
            throw new EncryptionException('Invalid corpId.', EncryptionException::ERROR_INVALID_CORPID);
        }

        return $xml;
    }
1371219
public static function decrypt($data) : string {
      $crypter = new Crypter();

      return $crypter->decrypt($data, self::getAppKey());
    }
1079897
public function decrypt($strEncryptedData)
    {
        if ($this->blnBase64) {
            $strEncryptedData = QString::base64UrlSafeDecode($strEncryptedData);
        }
        $strIv = $this->strIv;
        if ($this->strIvHashKey) {
            $offset = strrpos($strEncryptedData, ":");
            if ($offset === null) {
                throw new Q\Exception\Cryptography("Hash value not found.");
            }
            $hash1 = substr($strEncryptedData, $offset + 1);
            $strEncryptedData = substr($strEncryptedData, 0, $offset);

            // check for tampering
            $hash2 = hash_hmac('sha256', $strEncryptedData, $this->strIvHashKey);
            if ($hash1 != $hash2) {
                throw new Q\Exception\Cryptography("Encryption tampering detected");
            }

            $offset2 = strrpos($strEncryptedData, ":");

            if ($offset2 === null) {
                throw new Q\Exception\Cryptography("IV not found.");
            }
            $strIv = substr($strEncryptedData, $offset2 + 1);
            $strIv = hex2bin($strIv);    // undo our serialization encoding
            $strEncryptedData = substr($strEncryptedData, 0, $offset2);
        }
        $strDecryptedData = openssl_decrypt($strEncryptedData, $this->strCipher, $this->strKey, 0, $strIv);

        return $strDecryptedData;
    }
403827
protected function buildSignatureDataString(array $signatureData)
    {
        $signatureString = '';
        $delimiter = '';
        foreach ($signatureData as $key => $value) {
            $signatureString .= $delimiter . $key . '=' . $value;

            $delimiter = '&';
        }

        return $signatureString;
    }
55814
protected function prepareForUnserialization(string $data = null) : string
    {
        if ($data === null) {
            return '';
        }

        if ($this->usesEncryption) {
            if ($this->encrypter === null) {
                throw new LogicException('Encrypter not set on session handler');
            }

            try {
                return $this->encrypter->decrypt($data);
            } catch (SessionEncryptionException $ex) {
                return serialize([]);
            }
        } else {
            return $data;
        }
    }
945992
public function encrypt($data)
    {
        $nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
        $token = base64_encode($nonce.sodium_crypto_secretbox($data, $nonce, $this->key).'&&'.$this->key);

        return $token;
    }
1045625
public function decrypt($encrypted)
    {
        try {
            $iv = substr($this->key, 0, 16);
            $decrypted = openssl_decrypt($encrypted, 'AES-256-CBC', substr($this->key, 0, 32), OPENSSL_ZERO_PADDING, $iv);
        } catch (Exception $e) {
            return [ErrorCode::$DecryptAESError, null];
        }
        try {
            $pkcEncoder = new PKCS7Encoder();
            $result = $pkcEncoder->decode($decrypted);
            if (strlen($result) < 16) {
                return [ErrorCode::$DecryptAESError, null];
            }
            $content = substr($result, 16, strlen($result));
            $len_list = unpack("N", substr($content, 0, 4));
            $xml_len = $len_list[1];
            return [0, substr($content, 4, $xml_len), substr($content, $xml_len + 4)];
        } catch (Exception $e) {
            return [ErrorCode::$IllegalBuffer, null];
        }
    }
149177
public function encrypt(string $data): string
    {
        $this->throwExceptionIfKeyEmpty();

        $iv = \openssl_random_pseudo_bytes(\openssl_cipher_iv_length($this->method));
        $encrypted = \openssl_encrypt($data, $this->method, $this->key, 0, $iv);
        $data = \base64_encode($encrypted . '::' . $iv);

        return $data;
    }
87240
public function encrypt(string $decrypted): string {
        $status = openssl_public_encrypt($decrypted, $encrypted, $this);
        if(!$status) {
            throw new RuntimeException('Encrypt failed');
        }
        return $encrypted;
    }
780699
public function encrypt($data){
        $maxlength = $this->getMaxEncryptBlockSize($this->publicKey);
        $output='';
        while(strlen($data)){
            $input = substr($data, 0, $maxlength);
            $data = substr($data, $maxlength);
            openssl_public_encrypt($input, $encrypted, $this->publicKey);
            $output .= $encrypted;
        }
        $encryptedData =  base64_encode($output);
        return $encryptedData;
    }
1038732
protected function encodeData($serializedData)
    {
        $result = json_encode($serializedData);
        if ($result === false) {
            $errorCode = json_last_error();
            throw new JsonException("Failed serialize json.", $errorCode);
        }

        return $result;
    }
62255
private static function decryptCipherText($encryptedData, $wrappedReceiptKey, $pem)
    {
        // Unwrap key and get profile
        openssl_private_decrypt(base64_decode($wrappedReceiptKey), $unwrappedKey, $pem);

        // Decipher encrypted data with unwrapped key and IV
        $cipherText = openssl_decrypt(
            $encryptedData->getCipherText(),
            'aes-256-cbc',
            $unwrappedKey,
            OPENSSL_RAW_DATA,
            $encryptedData->getIv()
        );

        return $cipherText;
    }
1285544
public function encrypt(string $decrypted): string {
        $status = openssl_private_encrypt($decrypted, $encrypted, $this);
        if(!$status) {
            throw new RuntimeException('Encrypt failed');
        }
        return $encrypted;
    }
693743
public static function getKeyDataFromString(string $data): string
    {
        $versionTag = Binary::safeSubstr($data, 0, Halite::VERSION_TAG_LEN);
        $keyData = Binary::safeSubstr(
            $data,
            Halite::VERSION_TAG_LEN,
            -\SODIUM_CRYPTO_GENERICHASH_BYTES_MAX
        );
        $checksum = Binary::safeSubstr(
            $data,
            -\SODIUM_CRYPTO_GENERICHASH_BYTES_MAX,
            \SODIUM_CRYPTO_GENERICHASH_BYTES_MAX
        );
        $calc = \sodium_crypto_generichash(
            $versionTag . $keyData,
            '',
            \SODIUM_CRYPTO_GENERICHASH_BYTES_MAX
        );
        if (!\hash_equals($calc, $checksum)) {
            // @codeCoverageIgnoreStart
            throw new InvalidKey(
                'Checksum validation fail'
            );
            // @codeCoverageIgnoreEnd
        }
        \sodium_memzero($data);
        \sodium_memzero($versionTag);
        \sodium_memzero($calc);
        \sodium_memzero($checksum);
        return $keyData;
    }