Class: Hawk::Crypto::TSMac

Inherits:
Base
  • Object
show all
Defined in:
lib/hawk/crypto.rb

Instance Method Summary collapse

Methods inherited from Base

#==, #encode64, #eql?, #to_s

Constructor Details

#initialize(key, ts, algorithm = 'sha256') ⇒ TSMac

Returns a new instance of TSMac.



129
130
131
# File 'lib/hawk/crypto.rb', line 129

def initialize(key, ts, algorithm = 'sha256')
  @key, @ts, @algorithm = key, ts, algorithm
end

Instance Method Details

#digestObject



137
138
139
# File 'lib/hawk/crypto.rb', line 137

def digest
  @digest ||= OpenSSL::HMAC.digest(openssl_digest(@algorithm).new, @key, normalized_string)
end

#normalized_stringObject



133
134
135
# File 'lib/hawk/crypto.rb', line 133

def normalized_string
  @normalized_string ||= "hawk.1.ts\n#{@ts}\n"
end