Class: FNV
- Inherits:
-
Object
- Object
- FNV
- Defined in:
- lib/fnv.rb
Constant Summary collapse
- INIT32 =
0x811c9dc5
- INIT64 =
0xcbf29ce484222325
- PRIME32 =
0x01000193
- PRIME64 =
0x100000001b3
- MOD32 =
2 ** 32
- MOD64 =
2 ** 64
Instance Method Summary collapse
Instance Method Details
#fnv1_32(data) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fnv.rb', line 9 def fnv1_32(data) hash = INIT32 data.bytes.each do |byte| hash = (hash * PRIME32) % MOD32 hash = hash ^ byte end hash end |
#fnv1_64(data) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fnv.rb', line 20 def fnv1_64(data) hash = INIT64 data.bytes.each do |byte| hash = (hash * PRIME64) % MOD64 hash = hash ^ byte end hash end |