lib/rickshaw.rb in rickshaw-0.0.2 vs lib/rickshaw.rb in rickshaw-0.1.0
- old
+ new
@@ -1,18 +1,33 @@
-require 'digest/sha1'
-require 'rickshaw/version'
-require 'core_ext/string/to_sha1'
-
-module Rickshaw
- module SHA1
- def self.hash(file_path)
- hash = Digest::SHA1.new
- open(file_path, 'r') do |io|
- until io.eof?
- buffer = io.read(1024)
- hash.update(buffer)
- end
- end
- hash.hexdigest
- end
- end
-end
+require 'digest/sha1'
+require 'digest/sha2'
+require 'rickshaw/version'
+require 'core_ext/string/to_sha1'
+require 'core_ext/string/to_sha256'
+
+module Rickshaw
+ module SHA1
+ def self.hash(file_path)
+ hash = Digest::SHA1.new
+ open(file_path, 'r') do |io|
+ until io.eof?
+ buffer = io.read(1024)
+ hash.update(buffer)
+ end
+ end
+ hash.hexdigest
+ end
+ end
+
+ module SHA256
+ def self.hash(file_path)
+ hash = Digest::SHA256.new
+ open(file_path, 'r') do |io|
+ until io.eof?
+ buffer = io.read(1024)
+ hash.update(buffer)
+ end
+ end
+ hash.hexdigest
+ end
+ end
+end