WDA是H5ExtTransfer接口会用到的.在字段2中json请求内容名字为context_id
示例context_id: 33-9-141-W71dd244a27a4fe9a1762768491755
完整代码
import hashlib
import time
def calculate_device_id():
mac_all = "1C1B0D0E93981C1B0D0E9396"
cpuidtxt = "3219913727" # 需要转有符号 -1077150721
# 将无符号整数转换为有符号整数
cpuid_unsigned = int(cpuidtxt)
if cpuid_unsigned > 0x7FFFFFFF: # 如果大于最大有符号整数
cpuid_signed = cpuid_unsigned - 0x100000000
else:
cpuid_signed = cpuid_unsigned
# 使用有符号整数参与运算
cpuidtxt = str(cpuid_signed)
# print(cpuidtxt)
# 第一次MD5
mac_bytes = bytes.fromhex(mac_all)
macmd5 = hashlib.md5(mac_bytes).hexdigest().lower().replace(" ", "")
# 组合字符串
dev_md5 = macmd5 + cpuidtxt
# print(dev_md5)
# 第二次MD5
dev_bytes = dev_md5.encode('utf-8')
dev_hex = dev_bytes.hex()
dev_md5 = hashlib.md5(bytes.fromhex(dev_hex)).hexdigest().lower().replace(" ", "")
# 添加前缀并截取
result = "W" + dev_md5
return result[:17]
# 使用示例
if __name__ == "__main__":
device_id = calculate_device_id()
# 获取13位现行时间戳(毫秒级)
timestamp = str(int(time.time() * 1000))
# 组合设备ID和时间戳 33-9-141 传入参数固定的 只有部分业务 不同
final_result = "33-9-141-" + device_id + timestamp
print("context_id:", final_result)
PC微信WDA算法
AiXed2025-11-16 5:03
相关推荐
wuhen_n35 分钟前
网络请求在Vite层的代理与Mock:告别跨域和后端依赖用户69371750013845 小时前
Google 正在“收紧侧加载”:陌生 APK 安装或需等待 24 小时蓝帆傲亦6 小时前
Web 前端搜索文字高亮实现方法汇总用户69371750013846 小时前
Room 3.0:这次不是升级,是重来漫随流水7 小时前
旅游推荐系统(view.py)踩着两条虫8 小时前
VTJ.PRO 核心架构全公开!从设计稿到代码,揭秘AI智能体如何“听懂人话”jzlhll1239 小时前
kotlin Flow first() last()总结用头发抵命9 小时前
Vue 3 中优雅地集成 Video.js 播放器:从组件封装到功能定制蓝冰凌10 小时前
Vue 3 中 defineExpose 的行为【defineExpose暴露ref变量】详解:自动解包、响应性与实际使用奔跑的呱呱牛10 小时前
generate-route-vue基于文件系统的 Vue Router 动态路由生成工具