class HMAC::SHA512
Public Class Methods
digest(key, text)
click to toggle source
These two class methods below are safer than using above instance methods combinatorially because an instance will have held a key even if it's no longer in use.
# File lib/hmac/hmac.rb, line 88 def Base.digest(key, text) begin hmac = self.new(key) hmac.update(text) hmac.digest ensure hmac.reset_key end end
hexdigest(key, text)
click to toggle source
# File lib/hmac/hmac.rb, line 98 def Base.hexdigest(key, text) begin hmac = self.new(key) hmac.update(text) hmac.hexdigest ensure hmac.reset_key end end
new(key = nil)
click to toggle source
Calls superclass method
HMAC::Base.new
# File lib/hmac/sha2.rb, line 20 def initialize(key = nil) super(Digest::SHA512, 128, 64, key) end
new(algorithm, block_size, output_length, key)
click to toggle source
# File lib/hmac/hmac.rb, line 16 def initialize(algorithm, block_size, output_length, key) @algorithm = algorithm @block_size = block_size @output_length = output_length @status = STATUS_UNDEFINED @key_xor_ipad = '' @key_xor_opad = '' set_key(key) unless key.nil? end