summaryrefslogtreecommitdiff
path: root/ext/digest/lib
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-14 05:39:40 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-14 05:39:40 +0000
commitd6ff7b526a6b102940d06c0e70a21990203606cc (patch)
treef0b507cf131468a718163a40ba249d9423ca7420 /ext/digest/lib
parent29d039601206933b1a9e5a585807576d1ba8b780 (diff)
* ext/digest/lib/digest.rb (Digest::Base.file): new method.
[ruby-dev:29572] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/digest/lib')
-rw-r--r--ext/digest/lib/digest.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/ext/digest/lib/digest.rb b/ext/digest/lib/digest.rb
index b550f94..7703faa 100644
--- a/ext/digest/lib/digest.rb
+++ b/ext/digest/lib/digest.rb
@@ -5,4 +5,17 @@ module Digest
autoload "SHA256", "digest/sha2"
autoload "SHA384", "digest/sha2"
autoload "SHA512", "digest/sha2"
+
+ class Base
+ def self.file(name)
+ digest = self.new
+ File.open(name) {|f|
+ buf = ""
+ while f.read(16384, buf)
+ digest.update buf
+ end
+ }
+ digest
+ end
+ end
end