def elf_hash(key): hash_value = 0 for i in range(len(key)): hash_value = (hash_value << 4) + ord(key[i]) x = hash_value & 0xF0000000 if x != 0: hash_value ^= (x >> 24) hash_value &= ~x return hash_value