Skip to content

Instantly share code, notes, and snippets.

@vaiorabbit
Created May 26, 2013 13:53
Show Gist options
  • Save vaiorabbit/5652866 to your computer and use it in GitHub Desktop.
Save vaiorabbit/5652866 to your computer and use it in GitHub Desktop.
module Hashcode
FNV1_32A_INIT = 0x811c9dc5
FNV_32_PRIME = 0x01000193
UINT32_MAX = 2 ** 32
module_function
def fnv32a( str )
hval = FNV1_32A_INIT
str.bytes.each do |s|
hval = hval ^ s
hval = (hval * FNV_32_PRIME) % UINT32_MAX
end
return hval
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment