diff options
| author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-10-11 17:25:45 +0000 |
|---|---|---|
| committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-10-11 17:25:45 +0000 |
| commit | 53318c0ed62ca471f237694d2817381b3cb45f1f (patch) | |
| tree | c8f8d08bdb6d46fb3236647b0d62d915ca199239 /ext/digest/lib | |
| parent | f189f5687b021894d307784a511861aefea59a0c (diff) | |
| download | ruby-53318c0ed62ca471f237694d2817381b3cb45f1f.tar.gz ruby-53318c0ed62ca471f237694d2817381b3cb45f1f.tar.xz ruby-53318c0ed62ca471f237694d2817381b3cb45f1f.zip | |
* 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: http://svn.ruby-lang.org/repos/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.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/digest/lib/digest/hmac.rb b/ext/digest/lib/digest/hmac.rb index e6870f95c..746a9cee1 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 |
