I'm trying to integrate FNV hashing algorithm on a PHP-based project as part of a requirement to produce hashes for a variety of data (e.g. URLs, keywords).
I saw this implementation by Neven Boyanov. He mentioned that due to arithmetic limitations in PHP, he was forced to use bitwise-shifting and addition instead of multiplication. Is his implementation correct? My knowledge is somehow limited in this area of computer science so I can't verify it myself.
Another question that I have is about the different 'flavors' of FNV. I saw that it offers 32-bit, 64-bit, and 128-bit variants but using the above implemention I always get 8-character hex hashes (I convert the integer result to hex using dechex()).
Given the input "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin at libero mi, quis luctus massa.", I get the following hex results:
- (32-bit offset) 5b15c0f2
- (64-bit offset) 6ea33cb5
Why is this so? I'm expecting a 16-character hex result from the 64-bit FNV. Are the 'flavors' referring only to the kind of arithmetic operations and seeds that would be used and not to the length of the result? (i.e. if I say 64-bit FNV, the hashing function would use 64-bit operations and seed but the result would still be 32-bit)
A bit of enlightenment would be greatly appreciated :)