@Rohit: Let T be an array of length 256 that contains a permutation of
the numbers between 0 and 255. Then to hash string s[],

h = 0;
for( i = 0 ; s[i] ; ++i )
    h = T[h^s[i]];  // or  h = T[h] ^ s[i];

You can choose a random permutation for T, or, if you have a small
known set of strings (e.g. C keywords), you can try to tailor T so
that each given string has a unique hash value.

Dave

On Aug 14, 11:36 am, rohit <[email protected]> wrote:
> I came accross a problem where i need to hash strings..
> What is the best way to hash strings??

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to