工具箱相关
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.

Y1216decryption.py 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # -*- coding: utf-8 -*-
  2. import tkinter as tk
  3. from tkinter import filedialog as tkFileDialog
  4. import subprocess
  5. import io
  6. def start():
  7. window = tk.Tk() # 创建窗口对象的背景色
  8. window.title(u'解码用户的密码') # 设置窗口的标题
  9. window.geometry('400x250') # 设置窗口的大小
  10. title = tk.Label(window, text=u'解码机', font=(u'微软雅黑', 12), width=40, height=3)
  11. title.place(x=0,y=0,anchor='nw')
  12. # 输入密码
  13. pwd = tk.Label(window,text=u'输入密码:',font=(u'微软雅黑',12),width=20,height=2)
  14. pwd.place(x=0,y=50,anchor='nw')
  15. path_var1 = tk.StringVar() #输入路径
  16. entry1 = tk.Entry(window, textvariable=path_var1)
  17. entry1.place(x=170, y=65, anchor='nw')
  18. svpath = tk.Label(window,text=u'保存路径:',font=(u'微软雅黑',12),width=20,height=2)
  19. svpath.place(x=0,y=100,anchor='nw')
  20. path_var2 = tk.StringVar() #输入路径 5
  21. entry2 = tk.Entry(window, textvariable=path_var2)
  22. entry2.place(x=170, y=110, anchor='nw')
  23. svdate = tk.Label(window, text=u'有效日期至:\n(格式:20240101)', font=(u'微软雅黑', 12), width=20, height=2)
  24. svdate.place(x=0, y=150, anchor='nw')
  25. date_var2 = tk.StringVar() # 输入路径 5
  26. entry3 = tk.Entry(window, textvariable=date_var2)
  27. entry3.place(x=170, y=155, anchor='nw')
  28. def choose1():
  29. file_dir = tkFileDialog.askdirectory()
  30. path_var2.set(file_dir)
  31. def exchangewdinpy(date,path,wd,mac):
  32. # 替换文本
  33. source_file_path = 'passwordtxt_e.py'
  34. output_file_path = path + '\\' + wd + '.py'
  35. with io.open(source_file_path, 'r', encoding='utf-8') as source_file, io.open(output_file_path, 'w', encoding='utf-8') as output_file:
  36. line_number = 1
  37. for line in source_file:
  38. if line_number == 182:
  39. # 当达到第182行时,写入新的内容
  40. strmac = ' mac=\'' + mac + '\'\n'
  41. output_file.write(strmac)
  42. elif line_number == 184:
  43. strdate = ' date = \''+ date + '\'\n'
  44. output_file.write(strdate)
  45. else:
  46. # 否则,写入原内容
  47. output_file.write(line)
  48. line_number += 1
  49. # output_file_path = output_file_path.encode('utf-8')
  50. # path = path.encode('utf-8')
  51. subprocess.call([
  52. 'pyinstaller',
  53. '-F',
  54. output_file_path,# 这里替换为你的Python脚本文件名
  55. '--distpath',
  56. path
  57. ])
  58. def main():
  59. password = entry1.get()
  60. path = entry2.get()
  61. date = entry3.get()
  62. macNumber1= {'a':10,'b':11,'c':12,'d':13,'e':14,'f':15}
  63. macNumber2 = {10:'a',11:'b',12:'c',13:'d',14:'e',15:'f',-1:'f',-2:'e',-3:'d'}
  64. first = password[0:6]
  65. last = password[6:]
  66. newpassword = last + first
  67. strlist = [] #存放转换后的字符串
  68. for n in newpassword:
  69. try:
  70. n1 = macNumber1[n]
  71. except:
  72. n1 = n
  73. n2 = int(n1) - 3
  74. if n2 >= 10:
  75. n2 = macNumber2[n2]
  76. elif n2 < 0 :
  77. n2 = macNumber2[n2]
  78. strlist.append(str(n2))
  79. mac = ''.join(strlist)
  80. exchangewdinpy(date,path, password, mac)
  81. def tuichu():
  82. window.destroy()
  83. tk.Button(window, text='选择', command=choose1).place(x=320, y=105, anchor='nw')
  84. tk.Button(window,text=u'生成',command=main).place(x=120,y=200,anchor='nw')
  85. tk.Button(window,text=u'关闭',command=tuichu).place(x=230,y=200,anchor='nw')
  86. window.mainloop()
  87. if __name__ == '__main__':
  88. start()
  89. # start("0")