1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import uuid
- import tkinter as tk
-
- def macget():
- #获取mac
- node = uuid.getnode()
- mac = uuid.UUID(int = node).hex[-12:]
- return mac
-
- def is_number(str1):
- try:
- float(str1)
- return 1
- except ValueError:
- return -1
-
- def plusmac(mac):
- #字典先行
- letterto ={
- 'A':10,
- 'a':10,
- 'B':11,
- 'b':11,
- 'C':12,
- 'c':12,
- 'D':13,
- 'd':13,
- 'E':14,
- 'e':14,
- 'F':15,
- 'f':15
- }
- numto = {
- 10:'a',
- 11:'b',
- 12:'c',
- 13:'d',
- 14:'e',
- 15:'f',
- }
- newmac = []
- #读取每一位
- ii = 0
- while ii < 12:
- #读取单个,判断是否需要字典
- mm = mac[ii]
- nn = is_number(mm)
- if nn == 1:
- #是数字
- oo = int(mm) + 3
- #判断是否超过10
- if oo > 9:
- newnum = numto[oo]
- newmac.append(newnum)
- else:
- newmac.append(str(oo))
- else:
- oo = letterto[mm]
- overoo = int(oo) + 3
- if overoo < 16:
- newnum = numto[overoo]
- newmac.append(str(newnum))
- #整个都超了
- else:
- overoveroo = overoo - 16
- newmac.append(str(overoveroo))
- ii = ii + 1
- passmac = ''.join(newmac)
- return passmac
-
- def ordermac(mac):
- passt = mac[:6]
- passb = mac[6:12]
- neworder = []
- neworder.append(passb)
- neworder.append(passt)
- newpass = ''.join(neworder)
- return newpass
-
- def wdshow():
- def tuichu():
- wd.destroy()
- en_aa = macget()
- # print (aa)
- en_bb = plusmac(en_aa)
- # print(bb)
- en_cc = ordermac(en_bb)
- # print(cc)
- wd = tk.Toplevel() # 创建窗口对象的背景色
- wd.title('KEYGEN') # 设置窗口的标题
- wd.geometry('350x200') # 设置窗口的大小
- keytitle = tk.Label(wd, text='请复制下面的密钥给管理员:', font=('微软雅黑', 12), width=25)
- keytitle.place(x=10,y=10,anchor='nw')
- key_value = tk.StringVar(value=en_cc)
- keyentry1 = tk.Entry(wd, textvariable=key_value, font=('微软雅黑', 12), width=20, fg='red')
- keyentry1.place(x=10, y=75, anchor='nw')
- tk.Button(wd, text='关 闭',command=tuichu).place(x=100,y=135,anchor='nw')
- wd.mainloop()
|