I need an algorithm to hash a string of arbitrary length into a value from 1 through 26.
I realize that I could sum the values of the individual characters and do a mod 26 + 1, but thought maybe someone would have a more performant way of doing this.
Do you need to make hash values not to change across different runs of an app? If you don’t, and you want to use it in memory, simply use the system provided
GetHashCodefunction:will map a string to an integer between 1 and 26 inclusive. Of course, this is not really suitable for tasks like persisting in a database.