Hashing function for shortening 8 byte unique ID to 4 byte in C

Tibbe Source

I need to choose a hashing function to convert a unique 8 byte ID to a 4 byte ID (as unique as possible) on a 12-Bit micro-controller(MSP430) in C.

What hashing function would you suggest?

I found some functions here but I don't know which one to choose.

Update: here is an old similar question specifying the original unique ID format: Hashing a 64-bit value into a 32-bit MAC address

Update 2:

 RSHash((const uint8_t*)ID_8BYTE, 8); 

uint32_t RSHash(const uint8_t* key, unsigned int len)
{
   uint32_t b    = 378551;
   uint32_t a    = 63689;
   uint32_t hash = 0;
   uint32_t i    = 0;

   for(i = 0; i < len; key++, i++)
   {
      hash = hash * a + (*key);
      a    = a * b;
   }

   return hash;
}
chashmicrocontrolleruuiduniqueidentifier

Answers

comments powered by Disqus