Files
app_package/get_machine_code.py
2025-11-25 11:41:56 +08:00

18 lines
551 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import platform
import uuid
import hashlib
def get_machine_id() -> str:
"""生成机器码。
根据当前系统信息平台、架构、MAC地址生成唯一机器码
使用 SHA256 取前16位并转大写前缀为 HERTZ_STUDIO_。
"""
system_info = f"{platform.platform()}-{platform.machine()}-{uuid.getnode()}"
return 'HERTZ_STUDIO_' + hashlib.sha256(system_info.encode()).hexdigest()[:16].upper()
if __name__ == "__main__":
machine_code = get_machine_id()
print(f"您的机器码是: {machine_code}")