I use ELF Hash to write a specially modified version of the hash map. Desire to make collisions

Can someone give an example of two lines consisting only of alphabetic characters that will cause the same hash value using ELFHash?

I need these tests to check my codes. But it does not seem easy to manufacture. And, to my surprise, there are many examples of codes for various hash functions on the Internet, but none of them contain examples of collision strings.

Below is the ELF Hash if 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); } 
0
source share
1 answer

You can find a collision using brute force (for example, calculate all possible lines with a length of less than 5).

Some examples of collisions (which I got this way):

 hash = 23114: ------------- UMz SpJ hash = 4543841: --------------- AAAAQ AAABA hash = 5301994: --------------- KYQYZ KYQZJ KYRIZ KYRJJ KZAYZ 
+1
source

All Articles