工具箱相关
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

encryption.py 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 wdshow():
  76. def tuichu():
  77. wd.destroy()
  78. en_aa = macget()
  79. # print (aa)
  80. en_bb = plusmac(en_aa)
  81. # print(bb)
  82. en_cc = ordermac(en_bb)
  83. # print(cc)
  84. wd = tk.Toplevel() # 创建窗口对象的背景色
  85. wd.title('KEYGEN') # 设置窗口的标题
  86. wd.geometry('350x200') # 设置窗口的大小
  87. keytitle = tk.Label(wd, text='请复制下面的密钥给管理员:', font=('微软雅黑', 12), width=25)
  88. keytitle.place(x=10,y=10,anchor='nw')
  89. key_value = tk.StringVar(value=en_cc)
  90. keyentry1 = tk.Entry(wd, textvariable=key_value, font=('微软雅黑', 12), width=20, fg='red')
  91. keyentry1.place(x=10, y=75, anchor='nw')
  92. tk.Button(wd, text='关 闭',command=tuichu).place(x=100,y=135,anchor='nw')
  93. wd.mainloop()