Digest::Class
# File lib/compat/digest/hmac.rb, line 53 def initialize(key, digester) @md = digester.new block_len = @md.block_length if key.bytesize > block_len key = @md.digest(key) end ipad = Array.new(block_len).fill(0x36) opad = Array.new(block_len).fill(0x5c) key.bytes.each_with_index { |c, i| ipad[i] ^= c opad[i] ^= c } @key = key.freeze @ipad = ipad.inject('') { |s, c| s << c.chr }.freeze @opad = opad.inject('') { |s, c| s << c.chr }.freeze @md.update(@ipad) end
# File lib/compat/digest/hmac.rb, line 104 def block_length @md.block_length end
# File lib/compat/digest/hmac.rb, line 100 def digest_length @md.digest_length end
# File lib/compat/digest/hmac.rb, line 76 def initialize_copy(other) @md = other.instance_eval { @md.clone } end
# File lib/compat/digest/hmac.rb, line 108 def inspect sprintf('#<%s: key=%s, digest=%s>', self.class.name, @key.inspect, @md.inspect.sub(/^\#<(.*)>$/) { $1 }); end
# File lib/compat/digest/hmac.rb, line 86 def reset @md.reset @md.update(@ipad) self end
# File lib/compat/digest/hmac.rb, line 80 def update(text) @md.update(text) self end
Generated with the Darkfish Rdoc Generator 2.