Jenkins hash function should help you get started.
my current method is just adding all the ASCII numbers of the characters together and taking it mod the array size.
You discard important bit of information which is the position of the character in the string. That is a bad idea, since then strings "AB" and "BA" would have same the same hash value.
Instead of simple addition, keeping it primitive, one can use expression like hash = hash*P1 + str[i]*P2 + P3;
where Pi are some prime numbers. That's how I do it if I need a hash function quickly. I often use 7, 5 and 3 as the primes, but the numbers should be obviously adjusted (as well as initial value of hash
) so that the result of hash function is usable to your task.
For more information read the corresponding (and rather informative) Wikipedia article.