Hash functions for algorithmic use have usually 2 goals, first they have to be fast, second they have to evenly distibute the values across the possible numbers. The hash function also required to give the all same number for the same input value.
if your values are strings, here are some examples for bad hash functions:
string[0]
- the ASCII characters a-Z are way more often then othersstring.lengh()
- the most probable value is 1Good hash functions tries to use every bit of the input while keeping the calculation time minimal. If you only need some hash code, try to multiply the bytes with prime numbers, and sum them.