Sha256: c81496c1e7513e664cb90b6ad1c261dc9e7f00fdbe0805f493e7379cae93df87
Contents?: true
Size: 491 Bytes
Versions: 1
Compression:
Stored size: 491 Bytes
Contents
require File.expand_path(File.dirname(__FILE__) + '/../lib/primes') class Hasher def initialize(size) raise NonPrimeContainer unless FIRST_1K_PRIMES.include?(size) @size = size end def hash(input, length=input.length) hash = 0 length.times do |i| new_hash = hash << 0x7 ^ input[i] overflow = hash >> 0x15 & 0x1fc hash = new_hash ^ overflow end hash &= 0x7fffffff hash % @size end class NonPrimeContainer < StandardError; end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hasher-0.1.0 | lib/hasher.rb |