[Hashing Home][Home]
FNV (Fowler–Noll–Vo) is a non-cryptography hash function created by Glenn Fowler, Landon Curt Noll, and Kiem-Phong Vo. There are two main versions, of which 1a is the most up-to-date version.
FNV
[Hashing Home][Home]
FNV (Fowler–Noll–Vo) is a non-cryptography hash function created by Glenn Fowler, Landon Curt Noll, and Kiem-Phong Vo. There are two main versions, of which 1a is the most up-to-date version.
|
A basic test is:
Try "The quick brown fox jumps over the lazy dog" gives an FNV hash of A8B2F3117DE37ACE and F3F9B7F5E7E47110 for FNV1a Try "The quick brown fox jumps over the lazy dog." gives an FNV hash of 8B8DD4B8E989AC24 and 75C4D4D9092C6C5A for FNV1a
A test vector is [here]
An example of the coding is:
var hash3 = HashFactory.Hash64.CreateFNV(); ulong crc64_1 = hash3.ComputeString(message, Encoding.ASCII).GetULong(); var hash4 = HashFactory.Hash64.CreateFNV1a(); ulong crc64_2 = hash4.ComputeString(message, Encoding.ASCII).GetULong();
In Python:
from fnvhash import fnv1a_32, fnv1_32, fnv1a_64, fnv1_64 msg='The quick brown fox jumps over the lazy dog' print ("Message: ",msg) print ("FNV1 (32-bit):\t",hex(fnv1_32(msg.encode()))) print ("FNV1a (32-bit):\t",hex(fnv1a_32(msg.encode()))) print ("FNV1 (64-bit):\t",hex(fnv1_64(msg.encode()))) print ("FNV1a (64-bit):\t",hex(fnv1a_64(msg.encode())))
A test run:
Message: The quick brown fox jumps over the lazy dog FNV1 (32-bit): 0xe9c86c6e FNV1a (32-bit): 0x48fff90 FNV1 (64-bit): 0xa8b2f3117de37ace FNV1a (64-bit): 0xf3f9b7f5e7e47110