Module: Signatron
- Defined in:
- lib/signatron.rb,
lib/signatron/version.rb
Constant Summary collapse
- VERSION =
'0.1.0'
Class Method Summary collapse
Class Method Details
.sign(body, timestamp, timeout) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/signatron.rb', line 19 def self.sign(body, , timeout) setup data = body + '&' + .to_i.to_s + '&' + timeout.to_s @hmac.update data Base64.strict_encode64 @hmac.digest end |
.verify(body, timestamp, timeout, signature) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/signatron.rb', line 6 def self.verify(body, , timeout, signature) setup begin raise unless .to_i > Time.now.to_i - timeout proper_signature = self.sign body, , timeout signature == proper_signature rescue false end end |