feat: add root directory files and interactive module - Add account manager, test files, and interactive GUI module; Update requirements.txt
This commit is contained in:
38
test_hardware_id.py
Normal file
38
test_hardware_id.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import subprocess
|
||||
import hashlib
|
||||
import logging
|
||||
|
||||
def get_hardware_id() -> str:
|
||||
"""获取硬件唯一标识"""
|
||||
try:
|
||||
print("正在获取CPU信息...")
|
||||
cpu_info = subprocess.check_output('wmic cpu get ProcessorId').decode()
|
||||
cpu_id = cpu_info.split('\n')[1].strip()
|
||||
print(f"CPU ID: {cpu_id}")
|
||||
|
||||
print("\n正在获取主板序列号...")
|
||||
board_info = subprocess.check_output('wmic baseboard get SerialNumber').decode()
|
||||
board_id = board_info.split('\n')[1].strip()
|
||||
print(f"主板序列号: {board_id}")
|
||||
|
||||
print("\n正在获取BIOS序列号...")
|
||||
bios_info = subprocess.check_output('wmic bios get SerialNumber').decode()
|
||||
bios_id = bios_info.split('\n')[1].strip()
|
||||
print(f"BIOS序列号: {bios_id}")
|
||||
|
||||
# 组合信息并生成哈希
|
||||
combined = f"{cpu_id}:{board_id}:{bios_id}"
|
||||
print(f"\n组合信息: {combined}")
|
||||
|
||||
hardware_id = hashlib.md5(combined.encode()).hexdigest()
|
||||
print(f"\n生成的硬件ID: {hardware_id}")
|
||||
return hardware_id
|
||||
except Exception as e:
|
||||
print(f"获取硬件ID失败: {str(e)}")
|
||||
return ""
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("=== 硬件ID测试 ===\n")
|
||||
hardware_id = get_hardware_id()
|
||||
if hardware_id:
|
||||
print("\n测试完成!")
|
||||
Reference in New Issue
Block a user