Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove HMAC with nil secret from documentation #422

Merged
merged 2 commits into from Jun 4, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 1 addition & 15 deletions README.md
Expand Up @@ -76,6 +76,7 @@ puts decoded_token
* HS512 - HMAC using SHA-512 hash algorithm

```ruby
# The secret is required. A JWT::DecodeError will be raised if it isn't present.
boardfish marked this conversation as resolved.
Show resolved Hide resolved
hmac_secret = 'my$ecretK3y'

token = JWT.encode payload, hmac_secret, 'HS256'
Expand All @@ -85,21 +86,6 @@ puts token

decoded_token = JWT.decode token, hmac_secret, true, { algorithm: 'HS256' }

# Array
# [
# {"data"=>"test"}, # payload
# {"alg"=>"HS256"} # header
# ]
puts decoded_token

# Without secret key
token = JWT.encode payload, nil, 'HS256'

# eyJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoidGVzdCJ9.pVzcY2dX8JNM3LzIYeP2B1e1Wcpt1K3TWVvIYSF4x-o
puts token

decoded_token = JWT.decode token, nil, true, { algorithm: 'HS256' }

# Array
# [
# {"data"=>"test"}, # payload
Expand Down