Advertisement
Guest User

verify

a guest
Jan 30th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.38 KB | None | 0 0
  1. module Verify
  2.   # TODO: PUT YOUR API CLIENT SHARED SECRET
  3.   SHARED_SECRET = ""
  4.   def verify(data, hmac_header)
  5.     digest = OpenSSL::Digest.new('sha256')
  6.     calculated_hmac = Base64.strict_encode64(OpenSSL::HMAC.digest(digest, SHARED_SECRET, data)).strip
  7.     puts "calc is: " + calculated_hmac
  8.     ActiveSupport::SecurityUtils.secure_compare(hmac_header, calculated_hmac)
  9.   end
  10. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement