Class: Bloombroom::FNVB
- Inherits:
-
Object
- Object
- Bloombroom::FNVB
- Defined in:
- lib/bloombroom/hash/fnv_b.rb
Constant Summary collapse
- INIT32 =
0x811c9dc5
- INIT64 =
0xcbf29ce484222325
- PRIME32 =
0x01000193
- PRIME64 =
0x100000001b3
- MOD32 =
2 ** 32
- MOD64 =
2 ** 64
Class Method Summary collapse
Class Method Details
.fnv1_32(data) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bloombroom/hash/fnv_b.rb', line 12 def self.fnv1_32(data) hash = INIT32 data.each_byte do |byte| hash = (hash * PRIME32) % MOD32 hash = hash ^ byte end hash end |
.fnv1_64(data) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bloombroom/hash/fnv_b.rb', line 23 def self.fnv1_64(data) hash = INIT64 data.each_byte do |byte| hash = (hash * PRIME64) % MOD64 hash = hash ^ byte end hash end |