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:
parent
d754c11644
commit
0c80ce785d
2 changed files with 16 additions and 5 deletions
|
@ -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>
|
Fri Oct 20 22:00:43 2006 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
* ext/digest/lib/digest/hmac.rb: Complete half-boiled updates.
|
* ext/digest/lib/digest/hmac.rb: Complete half-boiled updates.
|
||||||
|
|
|
@ -16,20 +16,27 @@ module Digest
|
||||||
raise NameError, "Digest class not found: Digest::#{name}"
|
raise NameError, "Digest class not found: Digest::#{name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
class Base
|
class ::Digest::Class
|
||||||
# creates a digest object and read given file, _name_.
|
# creates a digest object and reads a given file, _name_.
|
||||||
#
|
#
|
||||||
# p Digest::SHA256.file("X11R6.8.2-src.tar.bz2").hexdigest
|
# p Digest::SHA256.file("X11R6.8.2-src.tar.bz2").hexdigest
|
||||||
# # => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534"
|
# # => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534"
|
||||||
def self.file(name)
|
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|
|
File.open(name, "rb") {|f|
|
||||||
buf = ""
|
buf = ""
|
||||||
while f.read(16384, buf)
|
while f.read(16384, buf)
|
||||||
digest.update buf
|
update buf
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
digest
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue