1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/digest/lib/digest.rb: Follow the framework updates.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2006-10-21 08:52:09 +00:00
parent d754c11644
commit 0c80ce785d
2 changed files with 16 additions and 5 deletions

View file

@ -1,3 +1,7 @@
Sat Oct 21 17:50:40 2006 Akinori MUSHA <knu@iDaemons.org>
* ext/digest/lib/digest.rb: Follow the framework updates.
Fri Oct 20 22:00:43 2006 Akinori MUSHA <knu@iDaemons.org>
* ext/digest/lib/digest/hmac.rb: Complete half-boiled updates.

View file

@ -16,20 +16,27 @@ module Digest
raise NameError, "Digest class not found: Digest::#{name}"
end
class Base
# creates a digest object and read given file, _name_.
class ::Digest::Class
# creates a digest object and reads a given file, _name_.
#
# p Digest::SHA256.file("X11R6.8.2-src.tar.bz2").hexdigest
# # => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534"
def self.file(name)
digest = self.new
new.file(name)
end
end
module Instance
# updates the digest with the contents of a given file _name_ and
# returns self.
def file(name)
File.open(name, "rb") {|f|
buf = ""
while f.read(16384, buf)
digest.update buf
update buf
end
}
digest
self
end
end
end