Sha256: 7f2c78ed77b73fc81176b03a3180d0fe64d658ad8ff15d7c0ea1f3040f53c635
Contents?: true
Size: 746 Bytes
Versions: 5
Compression:
Stored size: 746 Bytes
Contents
# frozen_string_literal: true require 'openssl' require 'digest/sha1' module ApiSignature class Generator SPLITTER = '|' TTL = 2.hours delegate :valid?, :expired?, :timestamp, to: :validator def initialize(options = {}) @options = options end def generate_signature(secret) hmac = OpenSSL::HMAC.digest(digest, secret, string_to_sign) Base64.encode64(hmac).chomp end private def validator Validator.new(@options) end def digest OpenSSL::Digest::SHA256.new end def string_to_sign [ @options[:request_method], @options[:path], @options[:access_key], timestamp.to_i ].map(&:to_s).join(SPLITTER) end end end
Version data entries
5 entries across 5 versions & 1 rubygems