Usually hashes wouldn't do sums, otherwise, stop and pots will have the same hash.
And you wouldn't limit it to the first n characters because otherwise house and houses would have the same hash.
Generally, hashes take values and multiply it by a prime number. So you can probably refer this:
int hash = 7;
for (int i = 0; i < strlen; i++)
{
hash = hash*31 + charAt(i);
}