Psecio\Jwt\Jwt::decrypt PHP Method

decrypt() public method

Decrypt given data wtih given key (and algorithm/IV)
public decrypt ( string $data, string $algorithm, string $iv, $key ) : string
$data string Data to decrypt
$algorithm string Algorithm to use for decrypting the data
$iv string
return string Decrypted data
    public function decrypt($data, $algorithm, $iv, $key)
    {
        if (!function_exists('openssl_encrypt')) {
            throw new \RuntimeException('Cannot encrypt data, OpenSSL not enabled');
        }
        // Decrypt just the claims
        $sections = explode('.', $data);
        if (count($sections) < 3) {
            throw new Exception\DecodeException('Invalid number of sections (<3)');
        }
        $claims = openssl_decrypt($this->base64Decode($sections[1]), $algorithm, $key, false, $iv);
        return json_decode($claims);
    }