def bp_hash(key): hash_value = 0 for i in range(len(key)): hash_value = hash_value << 7 ^ ord(key[i]) return hash_value