Hacker News new | past | comments | ask | show | jobs | submit login

The "ZOMGBadHash" isn't unique to that codebase - it's the hash specified by the ELF ABI (see http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#h... ).

It's not just a random mush of xors and shifts, it's:

  - Add the next character value to the current value;
  - Left-shift the current value by 4 (because most of the entropy in plain text ASCII is in the lower 4 bits);
  - XOR the top 4 bits into the bottom four bits of the current value, because they're going to get shifted out next time; then clear the top four bits.
It's still not a great hash function (obviously). Part of the issue is that with a 32-bit unsigned int it's effectively only a 28 bit hash.



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: