Sha256: b215df673a0801d077eb4f3a7f0bd86d65e729da950fd9977f47c902499531cc

Contents?: true

Size: 593 Bytes

Versions: 49

Compression:

Stored size: 593 Bytes

Contents

module Fog
  class HMAC
    def initialize(type, key)
      @key = key
      case type
      when "sha1"
        setup_sha1
      when "sha256"
        setup_sha256
      end
    end

    def sign(data)
      @signer.call(data)
    end

    private

    def setup_sha1
      @digest = OpenSSL::Digest.new("sha1")
      @signer = lambda do |data|
        OpenSSL::HMAC.digest(@digest, @key, data)
      end
    end

    def setup_sha256
      @digest = OpenSSL::Digest.new("sha256")
      @signer = lambda do |data|
        OpenSSL::HMAC.digest(@digest, @key, data)
      end
    end
  end
end

Version data entries

49 entries across 46 versions & 3 rubygems

Version Path
fog-core-2.6.0 lib/fog/core/hmac.rb
fog-core-2.5.0 lib/fog/core/hmac.rb
fog-core-2.4.0 lib/fog/core/hmac.rb
fog-core-2.3.0 lib/fog/core/hmac.rb
fog-core-2.2.4 lib/fog/core/hmac.rb
fog-core-2.2.3 lib/fog/core/hmac.rb
fog-core-2.2.2 lib/fog/core/hmac.rb
fog-core-2.2.1 lib/fog/core/hmac.rb
fog-core-2.2.0 lib/fog/core/hmac.rb
fog-core-2.1.2 lib/fog/core/hmac.rb
fog-core-2.1.1 lib/fog/core/hmac.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-core-1.45.0/lib/fog/core/hmac.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-core-1.45.0/lib/fog/core/hmac.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-core-2.1.0/lib/fog/core/hmac.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-core-1.45.0/lib/fog/core/hmac.rb
fog-core-2.1.0 lib/fog/core/hmac.rb
fog-core-2.0.0 lib/fog/core/hmac.rb
fog-core-1.45.0 lib/fog/core/hmac.rb
fog-core-1.44.3 lib/fog/core/hmac.rb
fog-core-1.44.2 lib/fog/core/hmac.rb