GeneralHashFunctions_4.py 258 B

123456789
  1. def elf_hash(key):
  2. hash_value = 0
  3. for i in range(len(key)):
  4. hash_value = (hash_value << 4) + ord(key[i])
  5. x = hash_value & 0xF0000000
  6. if x != 0:
  7. hash_value ^= (x >> 24)
  8. hash_value &= ~x
  9. return hash_value