Forked from lkdocs/Ruby OpenSSL: Verify Signature Example.rb
Created
August 5, 2020 18:32
-
-
Save wout/eb35817b171fc2230eb059cc047ce0c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
def verify_sign(key, signature, data) | |
# Verifies with a public key that the data was signed with their private key | |
pubkey = key.public_key | |
if pubkey.verify(OpenSSL::Digest::SHA256.new, signature, data) | |
puts 'the signature is valid' | |
else | |
puts 'the signature is invalid' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment