public static function createJWE($payload, array $shared_protected_headers = [], array $shared_headers = [], $aad = null)
{
$jwe = new JWE();
$jwe = $jwe->withSharedProtectedHeaders($shared_protected_headers);
$jwe = $jwe->withSharedHeaders($shared_headers);
$jwe = $jwe->withPayload($payload);
if (null !== $aad) {
$jwe = $jwe->withAAD($aad);
}
return $jwe;
}
/** * {@inheritdoc} */ public function encrypt($payload, array $encryption_protected_headers, Object\JWKInterface $encryption_key) { Assertion::true($this->isEncryptionSupportEnabled(), 'The encryption support is not enabled'); $jwe = Factory\JWEFactory::createJWE($payload, $encryption_protected_headers); $jwe = $jwe->addRecipientInformation($encryption_key); $this->encrypter->encrypt($jwe); return $jwe->toCompactJSON(0); }