Skip to content

Commit

Permalink
add: ES256 usage (#1003)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gautam-Hegde authored Oct 13, 2024
1 parent 6dc23b3 commit 4ceee5a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------------------

Expand Down

0 comments on commit 4ceee5a

Please sign in to comment.