Sha256: 4fa696507564c90b5770d6c662a1db9af549c6430f8875d586aee0257e8e19b9

Contents?: true

Size: 970 Bytes

Versions: 2

Compression:

Stored size: 970 Bytes

Contents

require 'digest/md5'
require 'digest/sha1'
require 'digest/sha2'
require 'rickshaw/version'
require 'core_ext/string/to_md5'
require 'core_ext/string/to_sha1'
require 'core_ext/string/to_sha256'

module Rickshaw
  module MD5
    def self.hash(file_path)
      hash = Digest::MD5.new
      open(file_path, 'r') do |io|
        until io.eof?
          buffer = io.read(1024)
          hash.update(buffer)
        end
      end
      hash.hexdigest
    end
  end

  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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rickshaw-0.3.0 lib/rickshaw.rb
rickshaw-0.2.0 lib/rickshaw.rb