Class: XSignature::HexSignatureValidator

Inherits:
SignatureValidator show all
Defined in:
lib/x-signature/hex_signature_validator.rb

Class Method Summary collapse

Methods inherited from SignatureValidator

#valid?

Class Method Details

.signature(secret:, nonce:, body:, method:, request_uri:) ⇒ Object



6
7
8
9
10
# File 'lib/x-signature/hex_signature_validator.rb', line 6

def self.signature(secret:, nonce:, body:, method:, request_uri:)
  sha512  = OpenSSL::Digest::SHA512.new
  request = "#{method.to_s.upcase}#{request_uri}#{sha512.hexdigest("#{nonce}#{body}")}"
  OpenSSL::HMAC.hexdigest(sha512, secret.to_s, request)
end