Sha256: 5054fbcb8eb57beedef33916467531a888b38c357e69baa6412f4afca47da24b

Contents?: true

Size: 1009 Bytes

Versions: 1

Compression:

Stored size: 1009 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'
require 'core_ext/string/byte_packing'

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

1 entries across 1 versions & 1 rubygems

Version Path
rickshaw-0.3.1 lib/rickshaw.rb