Sha256: 52a55ca1bbdd7867b76d1c93dc0962236104a464da976ec9f0dd1e1040b40163
Contents?: true
Size: 572 Bytes
Versions: 7
Compression:
Stored size: 572 Bytes
Contents
# frozen_string_literal: true require "openssl" require "base64" module Veryfi class Signature attr_reader :secret, :params, :timestamp def initialize(secret, params, timestamp) @secret = secret @params = params @timestamp = timestamp end def to_base64 Base64.encode64(digest).strip end # private def digest OpenSSL::HMAC.digest(OpenSSL::Digest.new("sha256"), secret, payload) end def payload "timestamp:#{timestamp}," + params.to_a.map { |i| "#{i[0]}:#{i[1]}" }.join(",") end end end
Version data entries
7 entries across 7 versions & 1 rubygems