#python hash和hive hash 保持一致
import hashlib
def get_group(hash_str):
md5_val = hashlib.md5((hash_str).encode("utf-8")).hexdigest()
hashcode = 0
for cha in md5_val:
hashcode = hashcode * 31 + ord(cha)
bytes_val = (hashcode + 2 ** (32 - 1)) % 2 ** 32 - 2 ** (32 - 1)
group = str(bytes_val)[-2:]
return group
imei='12345678'
hash_rule = 'aaa'
hash_str = imei + 'com' + imei[-2:] + 'bbb' + hash_rule
res=get_group(hash_str)
print(res)