Class: XSignature::Base64SignatureValidator

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

Class Method Summary collapse

Methods inherited from SignatureValidator

#valid?

Class Method Details

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



7
8
9
10
11
12
# File 'lib/x-signature/base64_signature_validator.rb', line 7

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