From 368c8038f402db5c30eef7fc41ac09b6e6829ef4 Mon Sep 17 00:00:00 2001 From: knu Date: Wed, 11 Oct 2006 17:25:45 +0000 Subject: * ext/digest: Merge from trunk; metadata location changed, Digest::Base#reset() added, Digest::Base#equal() changed, and digest/hmac added with some modifications for ruby 1.8. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/digest/lib/digest/hmac.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'ext/digest/lib') diff --git a/ext/digest/lib/digest/hmac.rb b/ext/digest/lib/digest/hmac.rb index e6870f95c1..746a9cee1d 100644 --- a/ext/digest/lib/digest/hmac.rb +++ b/ext/digest/lib/digest/hmac.rb @@ -51,12 +51,14 @@ module Digest @@algo = superclass def initialize(text = nil) - ipad = Array.new(BLOCK_LENGTH).fill(0x36) - opad = Array.new(BLOCK_LENGTH).fill(0x5c) + ipad = Array.new(@@algo::BLOCK_LENGTH).fill(0x36) + opad = Array.new(@@algo::BLOCK_LENGTH).fill(0x5c) - KEY.bytes.each_with_index { |c, i| + i = 0 + self.class::KEY.each_byte { |c| ipad[i] ^= c opad[i] ^= c + i += 1 } @ipad = ipad.inject('') { |s, c| s << c.chr } @@ -78,11 +80,11 @@ module Digest end def self.inspect - sprintf('#<%s.hmac(%s)>', @@algo.name, KEY.inspect); + sprintf('#<%s.hmac(%s)>', @@algo.name, self::KEY.inspect); end def inspect - sprintf('#<%s.hmac(%s): %s>', @@algo.name, KEY.inspect, hexdigest()); + sprintf('#<%s.hmac(%s): %s>', @@algo.name, self.class::KEY.inspect, hexdigest()); end } end -- cgit v1.2.3