I'm wondering if anyone has written a fast 8-bit hash function that is as good or better than CRC-8 for short (6-8byte) messages.

Here's the crc-8 code I found:

byte tempI; for (tempI = 8; tempI; tempI--) { byte sum = (hash ^ data) & 0x01; hash >>= 1; if (sum) { hash ^= 0x8C; } data >>= 1; }

I wrote a small test program to create 256 different 6-byte messages with random data using rand();

crc-8 had 78 hash collisions.

eor each byte had 96 collisions (and at 1 cycle per byte on an AVR is the fastest possible hash)

The best I could come up with after trying about a dozen different shift, add, subtract, eor combinations was the following, which could be done in 3 cycles on an AVR, and had 85 collisions:

char msb = data & 0x80; hash <<= 1; /* shift left */ hash -= data; if (msb) hash++;

Any suggestions?