@@ -171,49 +171,18 @@ decoded_token = JWT.decode(token, ecdsa_key, true, { algorithm: 'ES256' })
171171puts decoded_token
172172```
173173
174- ### ** EDDSA **
174+ ### ** EdDSA **
175175
176- In order to use this algorithm you need to add the ` RbNaCl ` gem to you ` Gemfile ` .
177-
178- ``` ruby
179- gem ' rbnacl'
180- ```
181-
182- For more detailed installation instruction check the official [ repository] ( https://github.com/RubyCrypto/rbnacl ) on GitHub.
183-
184- * ED25519
185-
186- ``` ruby
187- private_key = RbNaCl ::Signatures ::Ed25519 ::SigningKey .new (' abcdefghijklmnopqrstuvwxyzABCDEF' )
188- public_key = private_key.verify_key
189- token = JWT .encode payload, private_key, ' ED25519'
190-
191- # eyJhbGciOiJFRDI1NTE5In0.eyJkYXRhIjoidGVzdCJ9.6xIztXyOupskddGA_RvKU76V9b2dCQUYhoZEVFnRimJoPYIzZ2Fm47CWw8k2NTCNpgfAuxg9OXjaiVK7MvrbCQ
192- puts token
193-
194- decoded_token = JWT .decode token, public_key, true , { algorithm: ' ED25519' }
195- # Array
196- # [
197- # {"test"=>"data"}, # payload
198- # {"alg"=>"ED25519"} # header
199- # ]
200-
201- ```
176+ This algorithm has since version 3.0 been moved to the [ jwt-eddsa] ( https://rubygems.org/gems/jwt-eddsa ) gem.
202177
203178### ** RSASSA-PSS**
204179
205- In order to use this algorithm you need to add the ` openssl ` gem to your ` Gemfile ` with a version greater or equal to ` 2.1 ` .
206-
207- ``` ruby
208- gem ' openssl' , ' ~> 2.1'
209- ```
210-
211180* PS256 - RSASSA-PSS using SHA-256 hash algorithm
212181* PS384 - RSASSA-PSS using SHA-384 hash algorithm
213182* PS512 - RSASSA-PSS using SHA-512 hash algorithm
214183
215184``` ruby
216- rsa_private = OpenSSL ::PKey ::RSA .generate 2048
185+ rsa_private = OpenSSL ::PKey ::RSA .generate( 2048 )
217186rsa_public = rsa_private.public_key
218187
219188token = JWT .encode(payload, rsa_private, ' PS256' )
@@ -236,7 +205,7 @@ Ruby-jwt gem supports custom [header fields](https://tools.ietf.org/html/rfc7519
236205To add custom header fields you need to pass ` header_fields ` parameter
237206
238207``` ruby
239- token = JWT .encode(payload, key, algorithm = ' HS256' , header_fields= {})
208+ token = JWT .encode(payload, key, ' HS256' , header_fields= {})
240209```
241210
242211** Example:**
0 commit comments