This commit is contained in:
2025-11-25 11:41:56 +08:00
parent af24b473cd
commit c8228cc68f
3 changed files with 67 additions and 24 deletions

18
get_machine_code.py Normal file
View File

@@ -0,0 +1,18 @@
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}")