GeneralHashFunctions_11.py 300 B

12345678
  1. def ap_hash(key):
  2. hash_value = 0xAAAAAAAA
  3. for i in range(len(key)):
  4. if (i & 1) == 0:
  5. hash_value ^= ((hash_value << 7) ^ ord(key[i]) * (hash_value >> 3))
  6. else:
  7. hash_value ^= (~((hash_value << 11) + ord(key[i]) ^ (hash_value >> 5)))
  8. return hash_value