Skip to content

Commit

Permalink
Add EdDSA algorithm encoding/decoding usage (#993)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k authored Oct 8, 2024
1 parent e2bab76 commit 8910f56
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ RSA encoding and decoding require the ``cryptography`` module. See :ref:`install
>>> jwt.decode(encoded, public_key, algorithms=["PS256"])
{'some': 'payload'}
Encoding & Decoding Tokens with EdDSA (Ed25519)
-------------------------------------------

EdDSA encoding and decoding require the ``cryptography`` module. See :ref:`installation_cryptography`.

.. code-block:: pycon
>>> import jwt
>>> private_key = "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIPtUxyxlhjOWetjIYmc98dmB2GxpeaMPP64qBhZmG13r\n-----END PRIVATE KEY-----\n"
>>> public_key = "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEA7p4c1IU6aA65FWn6YZ+Bya5dRbfd4P6d4a6H0u9+gCg=\n-----END PUBLIC KEY-----\n"
>>> encoded = jwt.encode({"some": "payload"}, private_key, algorithm="EdDSA")
>>> jwt.decode(encoded, public_key, algorithms=["EdDSA"])
{'some': 'payload'}
Specifying Additional Headers
-----------------------------

Expand Down

0 comments on commit 8910f56

Please sign in to comment.