I'm using ELF Hash to write a specially tweaked version of hash map. Wanting to produce collisions

StackOverflow https://stackoverflow.com/questions/5920276

  •  29-10-2019
  •  | 
  •  

문제

Can any one give an example of 2 strings, consisting of alphabetical characters only, that will produce the same hash value with ELFHash?

I need these to test my codes. But it doesn't seem like easy to produce. And to my surprise there there are a lot of example codes of various hash function on the internet but none of them provides examples of collided strings.

Below is the ELF Hash, in case you need it.

unsigned int ELFHash(const std::string& str)
{
   unsigned int hash = 0;
   unsigned int x    = 0;

   for(std::size_t i = 0; i < str.length(); i++)
   {
      hash = (hash << 4) + str[i];
      if((x = hash & 0xF0000000L) != 0)
      {
         hash ^= (x >> 24);
         hash &= ~x;
      }
   }

   return (hash & 0x7FFFFFFF);
}

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top