Possible Duplicate:Which hashing algorithm is best for uniqueness and speed? I have created a hash algorithm and would like to test if it is usable. What do I need to test and how?
How to test if a hashing algorithm is good?
algorithms;testing;hashing
Short Answer: It depends on many-many factors. There is no such thing as a good hash function for universal hashes (although there is such a thing as universal hashing but it has different meaning).Depending on the context different criteria determine the quality of a hash. Some people may thing about SHA, however it is a cryptographic hash and it isn't at all good for hash tables which you probably mean.Longer Answer:Each hash tables has very specific requirements, and still finding a good hash function universally is hard because different data types expose different information that can be hashed. As a rule of thumb it is good to consider all information a type holds equally. This is not always easy or even possible. For reasons of statistics (and hence collision), it is also important to generate a good spread over the problem space, i.e. all possible objects. This means that when hashing numbers between 100 and 1050 it's no good to let the most significant digit play a big part in the hash because for ~ 90% of the objects, this digit will be 0. It's far more important to let the last three digits determine the hash.Another important thing when hashing strings is to consider all characters (except when it's known in advance that the first three characters of all strings will be the same: because it would be a waste)Edit: 1) Just to eliminate the confusion between hashing and encryption look here - Fundamental difference between Hashing and Encryption algorithms2) Also a good discussion on - What is the difference between a Hash Function and a Cryptographic Hash Function?References to look:For detailed guidance you may look what Knuth has to say in The Art of Computer Programming*, vol. 3.Julienne Walker's book on - The Art of HashingGood post by by Paul Hsieh - Hash functions