OneAtATime - Website

One-at-a-Time is one of the simpler, but slower, hashes. It is very solid and a much safer choice than the other hashes that process data one byte at a time. Perl 5.9 uses OneAtATime with a random seed.

Tests

Performance

Implementation

finline u32 fastcall OneAtATime( const u8 *key, u32 len, u32 seed ) {
	u32 hash = len + seed;
	while ( len-- ) {
		hash += ( *key++ );
		hash += ( hash << 10 );
		hash ^= ( hash >> 6 );
	}

	hash += ( hash << 3 );
	hash ^= ( hash >> 11 );
	hash += ( hash << 15 );
	return ( hash );
}