Module: CoinsPaid::API::Signature
- Defined in:
- lib/coins_paid/api/signature.rb
Class Method Summary collapse
Class Method Details
.check!(request_body:, key:, signature:) ⇒ Object
8 9 10 11 |
# File 'lib/coins_paid/api/signature.rb', line 8 def check!(request_body:, key:, signature:) key == API.public_key && signature == generate(request_body) || raise(InvalidSignatureError, 'Invalid signature') end |
.generate(request_body) ⇒ Object
13 14 15 |
# File 'lib/coins_paid/api/signature.rb', line 13 def generate(request_body) OpenSSL::HMAC.hexdigest('SHA512', API.secret_key, request_body) end |