Sha256: 07af5012bae592b47ee17f8c0622e9cb29532bee6b0cfaa44d076532fa79d28d
Contents?: true
Size: 580 Bytes
Versions: 1
Compression:
Stored size: 580 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::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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
veryfi-0.1.1 | lib/veryfi/signature.rb |