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

Handle null values in payload #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions verify_signature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ def verify_signature(secret, compact_json_payload, signature)
OpenSSL.secure_compare(signature, computed_hash)
end

payload = {
monday: '75F',
tuesday: '80F'
}
payload = '{
"key1": "value1",
"key2": null
}'
# Warning! JSON must be compact. Pretty JSON with spaces will not work.
compact_json_payload = payload.to_json
compact_json_payload = JSON.parse(payload).to_json

payload_signature = 'b7412f05e981a473b5ecbdb5393afaea02a679db6d7c8e56803512ec4ba98151'
payload_signature = 'x-checkr-signature value'

secret = 'test-secret'
puts verify_signature(secret, compact_json_payload, payload_signature) # should print true
secret = 'secret key'
puts verify_signature(secret, compact_json_payload, payload_signature) # should print true