Skip to content

Instantly share code, notes, and snippets.

@masukomi
Created June 1, 2013 18:35
Show Gist options
  • Save masukomi/5691306 to your computer and use it in GitHub Desktop.
Save masukomi/5691306 to your computer and use it in GitHub Desktop.
a failed attempt at a method that validates dwolla signatures
# This is a failed attempt to validate the signuature Dwolla passes back with
# a payment as described under *Dwolla's Signature on this page:
# https://developers.dwolla.com/dev/pages/button#configuration
Class Foo
def self.valid_dwolla_signature?(proposed_signature, checkout_id, amount)
require 'base64'
require 'openssl'
dwolla_secret = Figaro.env.dwolla_secret # our secret key
raw = "#{checkout_id}&#{amount}"
digest = OpenSSL::Digest::Digest.new('sha1')
#signature = OpenSSL::HMAC.digest(digest, dwolla_secret, raw)
signature = OpenSSL::HMAC.hexdigest(digest, dwolla_secret, raw)
# this ALWAYS generates the wrong signature
return (signature == proposed_signature)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment