summaryrefslogtreecommitdiff
path: root/ext/digest/lib
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-10-11 17:25:45 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-10-11 17:25:45 +0000
commit368c8038f402db5c30eef7fc41ac09b6e6829ef4 (patch)
treec8f8d08bdb6d46fb3236647b0d62d915ca199239 /ext/digest/lib
parentb3f7970ef9dbbb8e1470c10747cf45574b6fc399 (diff)
* 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
Diffstat (limited to 'ext/digest/lib')
-rw-r--r--ext/digest/lib/digest/hmac.rb12
1 files changed, 7 insertions, 5 deletions
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