|  | 
|  | 1 | +JSON Web Encryption | 
|  | 2 | +=================== | 
|  | 3 | + | 
|  | 4 | +JSON Web Encryption (JWE) are used to encrypt a payload and represent it as a | 
|  | 5 | +compact URL-safe string. | 
|  | 6 | + | 
|  | 7 | +Supported Content Encryption Algorithms | 
|  | 8 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 
|  | 9 | + | 
|  | 10 | +The following algorithms are currently supported. | 
|  | 11 | + | 
|  | 12 | ++------------------+------------------------------------------------+ | 
|  | 13 | +| Encryption Value | Encryption Algorithm, Mode, and Auth Tag       | | 
|  | 14 | ++==================+================================================+ | 
|  | 15 | +| A128CBC_HS256    | AES w/128 bit key in CBC mode w/SHA256 HMAC    | | 
|  | 16 | ++------------------+------------------------------------------------+ | 
|  | 17 | +| A192CBC_HS384    | AES w/128 bit key in CBC mode w/SHA256 HMAC    | | 
|  | 18 | ++------------------+------------------------------------------------+ | 
|  | 19 | +| A256CBC_HS512    | AES w/128 bit key in CBC mode w/SHA256 HMAC    | | 
|  | 20 | ++------------------+------------------------------------------------+ | 
|  | 21 | +| A128GCM          | AES w/128 bit key in GCM mode and GCM auth tag | | 
|  | 22 | ++------------------+------------------------------------------------+ | 
|  | 23 | +| A192GCM          | AES w/192 bit key in GCM mode and GCM auth tag | | 
|  | 24 | ++------------------+------------------------------------------------+ | 
|  | 25 | +| A256GCM          | AES w/256 bit key in GCM mode and GCM auth tag | | 
|  | 26 | ++------------------+------------------------------------------------+ | 
|  | 27 | + | 
|  | 28 | +Supported Key Management Algorithms | 
|  | 29 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 
|  | 30 | + | 
|  | 31 | +The following algorithms are currently supported. | 
|  | 32 | + | 
|  | 33 | ++-----------------+------------------------------------------------+ | 
|  | 34 | +| Algorithm Value | Key Wrap Algorithm                             | | 
|  | 35 | ++=================+================================================+ | 
|  | 36 | +| DIR             | Direct (no key wrap)                           | | 
|  | 37 | ++-----------------+------------------------------------------------+ | 
|  | 38 | +| RSA1_5          | RSAES with PKCS1 v1.5                          | | 
|  | 39 | ++-----------------+------------------------------------------------+ | 
|  | 40 | +| RSA_OAEP        | RSAES OAEP using default parameters            | | 
|  | 41 | ++-----------------+------------------------------------------------+ | 
|  | 42 | +| RSA_OAEP_256    | RSAES OAEP using SHA-256 and MGF1 with SHA-256 | | 
|  | 43 | ++-----------------+------------------------------------------------+ | 
|  | 44 | +| A128KW          | AES Key Wrap with default IV using 128-bit key | | 
|  | 45 | ++-----------------+------------------------------------------------+ | 
|  | 46 | +| A192KW   m      | AES Key Wrap with default IV using 192-bit key | | 
|  | 47 | ++-----------------+------------------------------------------------+ | 
|  | 48 | +| A256KW          | AES Key Wrap with default IV using 256-bit key | | 
|  | 49 | ++-----------------+------------------------------------------------+ | 
|  | 50 | + | 
|  | 51 | +Examples | 
|  | 52 | +^^^^^^^^ | 
|  | 53 | + | 
|  | 54 | +Encrypting Payloads | 
|  | 55 | +------------------- | 
|  | 56 | + | 
|  | 57 | +.. code:: python | 
|  | 58 | +
 | 
|  | 59 | +        >>> from jose import jwe | 
|  | 60 | +        >>> jwe.encrypt('Hello, World!', 'asecret128bitkey', algorithm='dir', encryption='A128GCM') | 
|  | 61 | +        'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4R0NNIn0..McILMB3dYsNJSuhcDzQshA.OfX9H_mcUpHDeRM4IA.CcnTWqaqxNsjT4eCaUABSg' | 
|  | 62 | +
 | 
|  | 63 | +
 | 
|  | 64 | +Decrypting Payloads | 
|  | 65 | +-------------------------- | 
|  | 66 | + | 
|  | 67 | +.. code:: python | 
|  | 68 | +
 | 
|  | 69 | +        >>> from jose import jwe | 
|  | 70 | +        >>> jwe.decrypt('eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4R0NNIn0..McILMB3dYsNJSuhcDzQshA.OfX9H_mcUpHDeRM4IA.CcnTWqaqxNsjT4eCaUABSg', 'asecret128bitkey') | 
|  | 71 | +        'Hello, World!' | 
0 commit comments