tab_hash_2.py 271 B

1234567891011
  1. def tab_hash(key):
  2. hash = 0
  3. i = 0
  4. for c in key:
  5. c_int = ord(c)
  6. hash_partial = hmap[c_int] ^ (c_int << i)
  7. hash ^= hash_partial
  8. i += 1
  9. # print(f"{c} : {hash_partial} : {hash}")
  10. # i+= hmap[i & 0xFF]
  11. return hash