module SamplingHash
Constants
- VERSION
Public Class Methods
hash(path, seed = File.size(path), hash = XXhash::XXhashInternal::StreamingHash64.new(seed))
click to toggle source
We default to 64 bit xxhash.
# File lib/sampling-hash.rb, line 9 def self.hash(path, seed = File.size(path), hash = XXhash::XXhashInternal::StreamingHash64.new(seed)) raise ArgumentError, 'file not found' unless File.file?(path) File.open(path, 'r') do |fd| sio = SamplingIO.new(fd) sio.samples do |chunk| hash.update(chunk) end hash.digest end end
hash32(path, seed = File.size(path))
click to toggle source
# File lib/sampling-hash.rb, line 24 def self.hash32(path, seed = File.size(path)) hash path, seed, XXHash::XXhashInternal::StreamingHash32.new(seed) end
hash64(path, seed = File.size(path))
click to toggle source
# File lib/sampling-hash.rb, line 28 def self.hash64(path, seed = File.size(path)) hash path, seed, XXHash::XXhashInternal::StreamingHash64.new(seed) end