Python 获取硬盘 主板等生产注册码

cpp 复制代码
import wmi
import random
import os

sec="t95p0q2f6dz1cxmowgjensr7yh384bvualki"
dec="dn7vhlk3wx1efsyc56zu2bomjtq8i0g4rp9a"

c=wmi.WMI()

for physical_disk in c.Win32_DiskDrive():
    hard_seral=physical_disk.SerialNumber #获取硬盘系列号
    print("硬盘系列号为:",hard_seral)
if len(hard_seral)>6:
    hard_seral=hard_seral[-6:]
else:
    print("硬盘信息获取错误!")
    os.exit(0)
for cpu in c.Win32_Processor():
    cpu_seral=cpu.ProcessorId.strip()  #获取CPU系列号
    print("CPU系列号为:",cpu_seral)
if len(cpu_seral)>4:
    cpu_seral=cpu_seral[-4:]
else:
    print("CPU信息获取错误!")
    os.exit(0)
for board_id in c.Win32_BaseBoard():
    board_id=board_id.SerialNumber #获取主板系列号
    print("主板系列号为:",board_id)
if len(board_id)>6:
    board_id=board_id[-5:]
else:
    print("主板信息获取错误!")
    os.exit(0)
seral=hard_seral+cpu_seral+board_id
print("注册码使用的硬件信息为:",seral)
cha_seral=""
for i in range(0,14,2):
    cha_seral+=seral[14-i]+seral[i+1] #字符串尾和首递进连接生成新的字符串
cha_seral=cha_seral+seral[7]          #字符串的中间值放到新的字符串
list_seral=list(cha_seral)            #字符串转为列表
list_seral.reverse()                  #列表反转
rand_seral=""

for i in range(10):             # 将前10个字符串和其位置索引
    j=random.randint(1,len(list_seral))
    rand_seral+=hex(j)[2:]+list_seral[j-1] #hex(j[2:],去掉16进制前的符号0x
    list_seral.remove(list_seral[j-1])
rand_seral=''.join(list_seral)+rand_seral #形成25位的字符串
low_seral=""
rand_seral=rand_seral.lower()
for item in rand_seral:
    j=sec.index(item)
    low_seral+=dec[j]
low_seral=low_seral.upper()
last_seral=low_seral[0:5]+"-"+low_seral[5:10]+"-"+low_seral[10:15]+"-"+low_seral[15:20]+"-"+low_seral[20:25]
print("生成的注册码为:\n",last_seral)
相关推荐
钱栈up41 分钟前
GitHub 热榜上手|anthropics/skills:18.9万星的 Claude 技能库
python·开源·github
钱栈up2 小时前
烧结秤校准改造:一个 0.93 系数差点让整条日报线算错数
爬虫·python·数据分析
IT空门:门主7 小时前
Spring AI 2.1.0 更新了什么:从 2.0 升上来的完整梳理
人工智能·python·spring
3095566668 小时前
股票接口重试怎么分类:正常、空数组与错误响应的幂等处理
java·大数据·开发语言·数据库·php·api接口·股票数据api接口
AI创界者8 小时前
Python 进阶实战(七十章):遗留系统重构、渐进式绞杀与技术债治理实战
人工智能·python·aigc
ZhengEnCi9 小时前
电脑操作 Agent 一直点不中:截图没更新时,提示词该怎么改才能停止瞎试
人工智能·python·agent
凌镜icecraft9 小时前
我改文件扩展名的时候那个警告弹窗再也不会弹出来了
windows·c#·wpf·explorer
郝学胜-神的一滴9 小时前
Effective STL 条款09:慎重选择删除元素的方法
开发语言·网络·数据结构·c++·算法·stl
Wellijohn11 小时前
dict、tuple、dataclass 还是 slots?我把 6 种数据载体的 8 项开销全测了一遍
后端·python·性能优化