工具箱相关
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

encryption.py 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import uuid
  2. import tkinter as tk
  3. def macget():
  4. #获取mac
  5. node = uuid.getnode()
  6. mac = uuid.UUID(int = node).hex[-12:]
  7. return mac
  8. def is_number(str1):
  9. try:
  10. float(str1)
  11. return 1
  12. except ValueError:
  13. return -1
  14. def plusmac(mac):
  15. #字典先行
  16. letterto ={
  17. 'A':10,
  18. 'a':10,
  19. 'B':11,
  20. 'b':11,
  21. 'C':12,
  22. 'c':12,
  23. 'D':13,
  24. 'd':13,
  25. 'E':14,
  26. 'e':14,
  27. 'F':15,
  28. 'f':15
  29. }
  30. numto = {
  31. 10:'a',
  32. 11:'b',
  33. 12:'c',
  34. 13:'d',
  35. 14:'e',
  36. 15:'f',
  37. }
  38. newmac = []
  39. #读取每一位
  40. ii = 0
  41. while ii < 12:
  42. #读取单个,判断是否需要字典
  43. mm = mac[ii]
  44. nn = is_number(mm)
  45. if nn == 1:
  46. #是数字
  47. oo = int(mm) + 3
  48. #判断是否超过10
  49. if oo > 9:
  50. newnum = numto[oo]
  51. newmac.append(newnum)
  52. else:
  53. newmac.append(str(oo))
  54. else:
  55. oo = letterto[mm]
  56. overoo = int(oo) + 3
  57. if overoo < 16:
  58. newnum = numto[overoo]
  59. newmac.append(str(newnum))
  60. #整个都超了
  61. else:
  62. overoveroo = overoo - 16
  63. newmac.append(str(overoveroo))
  64. ii = ii + 1
  65. passmac = ''.join(newmac)
  66. return passmac
  67. def ordermac(mac):
  68. passt = mac[:6]
  69. passb = mac[6:12]
  70. neworder = []
  71. neworder.append(passb)
  72. neworder.append(passt)
  73. newpass = ''.join(neworder)
  74. return newpass
  75. def tuichu():
  76. window.destroy()
  77. if __name__ == '__main__':
  78. aa = macget()
  79. # print (aa)
  80. bb = plusmac(aa)
  81. # print(bb)
  82. cc = ordermac(bb)
  83. # print(cc)
  84. window = tk.Tk() # 创建窗口对象的背景色
  85. window.title('KEYGEN') # 设置窗口的标题
  86. window.geometry('350x200') # 设置窗口的大小
  87. title = tk.Label(window, text='请使用 Ctrl + C 复制下面的密钥:', font=('微软雅黑', 12), width=25)
  88. title.place(x=10,y=10,anchor='nw')
  89. path_var1 = tk.StringVar()
  90. entry1 = tk.Entry(window, textvariable=path_var1, font=('微软雅黑', 12), width=20, fg ='red')
  91. entry1.place(x=10, y=75, anchor='nw')
  92. path_var1.set(cc)
  93. tk.Button(window,text='关 闭',command=tuichu).place(x=100,y=135,anchor='nw')
  94. window.mainloop()