public function encrypt($algorithm, $iv, $key)
{
if (!function_exists('openssl_encrypt')) {
throw new \RuntimeException('Cannot encrypt data, OpenSSL not enabled');
}
$data = json_encode($this->getClaims()->toArray(), JSON_UNESCAPED_SLASHES);
$claims = $this->base64Encode(openssl_encrypt($data, $algorithm, $key, false, $iv));
return $this->encode($claims);
}