Generate a JWE Serialization. It will automatically generate a compact or JSON serialization depending on `header` argument. If `header` is a dict with "protected", "unprotected" and/or "recipients" keys, it will call `serialize_json`, otherwise it will call `seriali
(self, header, payload, key, sender_key=None)
| 424 | return obj |
| 425 | |
| 426 | def serialize(self, header, payload, key, sender_key=None): |
| 427 | """Generate a JWE Serialization. |
| 428 | |
| 429 | It will automatically generate a compact or JSON serialization depending |
| 430 | on `header` argument. If `header` is a dict with "protected", |
| 431 | "unprotected" and/or "recipients" keys, it will call `serialize_json`, |
| 432 | otherwise it will call `serialize_compact`. |
| 433 | |
| 434 | :param header: A dict of header(s) |
| 435 | :param payload: Payload (bytes or a value convertible to bytes) |
| 436 | :param key: Public key(s) used to encrypt payload |
| 437 | :param sender_key: Sender's private key in case |
| 438 | JWEAlgorithmWithTagAwareKeyAgreement is used |
| 439 | :return: JWE compact serialization as bytes or |
| 440 | JWE JSON serialization as dict |
| 441 | """ |
| 442 | if "protected" in header or "unprotected" in header or "recipients" in header: |
| 443 | return self.serialize_json(header, payload, key, sender_key) |
| 444 | |
| 445 | return self.serialize_compact(header, payload, key, sender_key) |
| 446 | |
| 447 | def deserialize_compact(self, s, key, decode=None, sender_key=None): |
| 448 | """Extract JWE Compact Serialization. |