工具箱相关
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

encryption.py 2.4KB

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