September 6th, 2009, 11:58 AM
Hashing keys into a 1-byte result with no collisions
I'm having trouble implementing a hash function that produces 1-byte hash values (ranging from 0-255) for variable length keys. I've tried the Generalized CRC and Pearson algorithms described here.
While the CRC one works great, seemingly with no collisions based on my tests, it produces 4-byte hashes which are not very convenient for my purposes. Pearson gives me 1-byte hashes but I get around 60+ collisions in a 256-element key set (the keys are all unique) which is not very convenient either.
Is there a way to either reduce a 4-byte hash value into a 1-byte hash while preserving the non-colliding-ness or make the Pearson algorithm to produce fewer collisions with 1-byte hashes?
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.