hash function for mac needed

Dave Harris Dave.Harris at f14.n15.z1.fidonet.org
Fri Jun 21 15:11:40 AEST 1991


In a message of <Jun 18 20:29>, Chris Torek (1:114/15) writes: 

 >Indeed: as it turns out, while many people have spent much time looking
 >for `good' hashing functions, fewer seem to have noted that many
 >hashing systems spend more time computing hashes than searching.  I
 >find that this is usually the case, and that a fast hash function is
 >better than a slower-but-better-distribution function.  One good hash
 >function, useful in many applications, is this:

 >        hash = 0;
 >        for (each character)
 >                hash = (hash * 33) + (the character);
 >        hash_index = hash & ((some power of two) - 1);

Is the *33 use to keep short sequences has key more random or does it really 
help in the distribution of large string too?

  

 


 

--  
Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!15!14!Dave.Harris
Internet: Dave.Harris at f14.n15.z1.fidonet.org



More information about the Comp.lang.c mailing list