在模拟Android手机登录steam并进行身份验证的时候,
需要用到devicid,
所以跟具steamid来生成deviceid
from Cryptodome.Hash import HMAC,SHA1
from binascii import hexlify #返回的二进制数据的十六进制表示
def sha1_hash(data):
'''
param input type: str
param output type: bytes
'''
return SHA1.new(data.encode('ascii')).digest()
def generate_device_id(steamid_sha1_hash):
'''
param input type: bytes
param output type: str
'''
h = hexlify(steamid_sha1_hash).decode('ascii') #码流转换
return "android:%s-%s-%s-%s-%s" % (h[:8], h[8:12], h[12:16], h[16:20], h[20:32])
steamid_sha1_hash = sha1_hash('7657436883')
print(steamid_sha1_hash)
deviceid = generate_device_id(steamid_sha1_hash)
print('\ndeviceid\n',deviceid)