encrypt() public method

public encrypt ( Jose\Object\JWEInterface &$jwe )
$jwe Jose\Object\JWEInterface
Beispiel #1
0
 /**
  * {@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);
 }
 /**
  * @param string $payload
  * @param array  $protected_headers
  * @param array  $sender_key
  *
  * @return string
  */
 public function encrypt($payload, array $protected_headers, array $sender_key = [])
 {
     $sender_key = empty($sender_key) ? null : new JWK($sender_key);
     $instruction = new EncryptionInstruction($this->encryption_key, $sender_key);
     return $this->encrypter->encrypt($payload, [$instruction], JSONSerializationModes::JSON_COMPACT_SERIALIZATION, $protected_headers);
 }