Class: Net::HTTP::Signature::Signer

Inherits:
Object
  • Object
show all
Defined in:
lib/net/http/signature/signer.rb

Instance Method Summary collapse

Constructor Details

#initialize(request:, algorithm:, secret:) ⇒ Signer

Returns a new instance of Signer.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/net/http/signature/signer.rb', line 5

def initialize(request:, algorithm:, secret:)
  @request = request
  @algorithm = algorithm
  @secret = secret

  unless @algorithm =~ /.+-.+/
    fail ArgumentError, "Invalid algorithm format: {{key}}-{{digester}}"
  end

  unless key
    fail ArgumentError, "Crypto scheme not supported"
  end
end

Instance Method Details

#algorithmObject



19
20
21
# File 'lib/net/http/signature/signer.rb', line 19

def algorithm
  @algorithm
end

#to_sObject



23
24
25
# File 'lib/net/http/signature/signer.rb', line 23

def to_s
  Base64.encode64(key.update(request).digest)
end