summaryrefslogtreecommitdiff
path: root/ext/digest/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-14 07:28:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-14 07:28:26 +0000
commit69f1e595bfd768433a55528819691c41c78c962f (patch)
treed96b879a88f11d72d46c905aa3daf72fec99fcf3 /ext/digest/lib
parent0ff3bf4f44b7c634afcbcc08eb1cbe74f04ac37c (diff)
* ext/digest/lib/digest/hmac.rb (Digest::HMAC#initialize): faster
code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/digest/lib')
-rw-r--r--ext/digest/lib/digest/hmac.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/digest/lib/digest/hmac.rb b/ext/digest/lib/digest/hmac.rb
index f50fef2..1948352 100644
--- a/ext/digest/lib/digest/hmac.rb
+++ b/ext/digest/lib/digest/hmac.rb
@@ -49,8 +49,8 @@ module Digest
key = @md.digest(key)
end
- ipad = Array.new(block_len).fill(0x36)
- opad = Array.new(block_len).fill(0x5c)
+ ipad = Array.new(block_len, 0x36)
+ opad = Array.new(block_len, 0x5c)
key.bytes.each_with_index { |c, i|
ipad[i] ^= c
@@ -58,8 +58,8 @@ module Digest
}
@key = key.freeze
- @ipad = ipad.inject('') { |s, c| s << c.chr }.freeze
- @opad = opad.inject('') { |s, c| s << c.chr }.freeze
+ @ipad = ipad.pack('C*').freeze
+ @opad = opad.pack('C*').freeze
@md.update(@ipad)
end
@@ -102,7 +102,7 @@ module Digest
end
if $0 == __FILE__
- eval DATA.read, nil, $0, __LINE__+4
+ eval DATA.gets(nil), nil, $0, DATA.lineno
end
__END__