diff --git a/docs/usage.rst b/docs/usage.rst index 3abea93f..160d65c3 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -72,6 +72,21 @@ EdDSA encoding and decoding require the ``cryptography`` module. See :ref:`insta >>> jwt.decode(encoded, public_key, algorithms=["EdDSA"]) {'some': 'payload'} +Encoding & Decoding Tokens with ES256 (ECDSA) +------------------------------------------- + +ECDSA encoding and decoding require the ``cryptography`` module. See :ref:`installation_cryptography`. + +.. code-block:: pycon + + >>> import jwt + >>> private_key = b"-----BEGIN EC PRIVATE KEY-----\nMHcCAQEEIHAhM7P6HG3LgkDvgvfDeaMA6uELj+jEKWsSeOpS/SfYoAoGCCqGSM49\nAwEHoUQDQgAEXHVxB7s5SR7I9cWwry/JkECIRekaCwG3uOLCYbw5gVzn4dRmwMyY\nUJFcQWuFSfECRK+uQOOXD0YSEucBq0p5tA==\n-----END EC PRIVATE KEY-----\n" + >>> public_key = b"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEXHVxB7s5SR7I9cWwry/JkECIReka\nCwG3uOLCYbw5gVzn4dRmwMyYUJFcQWuFSfECRK+uQOOXD0YSEucBq0p5tA==\n-----END PUBLIC KEY-----\n" + >>> encoded = jwt.encode({"some": "payload"}, private_key, algorithm="ES256") + >>> jwt.decode(encoded, public_key, algorithms=["ES256"]) + {'some': 'payload'} + + Specifying Additional Headers -----------------------------