|
|
@ -1,81 +0,0 @@
|
|
|
|
from tkinter import LEFT, RIGHT, Button, Entry, StringVar, ttk
|
|
|
|
|
|
|
|
from tkinter.filedialog import askopenfilename
|
|
|
|
|
|
|
|
from tkinter.tix import Tk # 升级的组合控件包
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from client_createcip import createcip
|
|
|
|
|
|
|
|
from client_sendcipkey import sendcipkey
|
|
|
|
|
|
|
|
from client_senddata import senddata
|
|
|
|
|
|
|
|
from client_sendsig import sendsig
|
|
|
|
|
|
|
|
from client_twokey import client_twokey
|
|
|
|
|
|
|
|
from ttkbootstrap import Style
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def init_window():
|
|
|
|
|
|
|
|
# 创建窗口
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
global root
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
root = Tk()
|
|
|
|
|
|
|
|
style = Style(theme='minty')
|
|
|
|
|
|
|
|
root.title("客户端")
|
|
|
|
|
|
|
|
root.geometry("700x500")
|
|
|
|
|
|
|
|
root.configure(bg='white')
|
|
|
|
|
|
|
|
root.resizable(width=True, height=True) # 设置窗口是否可以变化长/宽,False不可变,True可变,默认为True
|
|
|
|
|
|
|
|
root.tk.eval("package require Tix")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 创建文本框
|
|
|
|
|
|
|
|
path = StringVar()
|
|
|
|
|
|
|
|
path.set("请选择文件")
|
|
|
|
|
|
|
|
ttk.Entry(root, textvariable=path, width=25,bootstyle="info").place(x=30,y=120,width=180,height=30)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def selectPath():
|
|
|
|
|
|
|
|
# 选择文件path_接收文件地址
|
|
|
|
|
|
|
|
path_ = askopenfilename()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 通过replace函数替换绝对文件地址中的/来使文件可被程序读取
|
|
|
|
|
|
|
|
# 注意:\\转义后为\,所以\\\\转义后为\\
|
|
|
|
|
|
|
|
path_ = path_.replace("/", "\\\\")
|
|
|
|
|
|
|
|
# path设置path_的值
|
|
|
|
|
|
|
|
path.set(path_)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 创建按钮
|
|
|
|
|
|
|
|
ttk.Button(root, text="选择文件", command=selectPath,bootstyle="info").place(x=220,y=120)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model = StringVar()
|
|
|
|
|
|
|
|
model.set("选择加密模式")
|
|
|
|
|
|
|
|
values = ["DES", "AES_ECB", "AES_CBC"]
|
|
|
|
|
|
|
|
ttk.Combobox(
|
|
|
|
|
|
|
|
master=root, # 父容器
|
|
|
|
|
|
|
|
height=3, # 高度,下拉显示的条目数量
|
|
|
|
|
|
|
|
width=15, # 宽度
|
|
|
|
|
|
|
|
state="normal", # 设置状态 normal(可选可输入)、readonly(只可选)、 disabled
|
|
|
|
|
|
|
|
cursor="arrow", # 鼠标移动时样式 arrow, circle, cross, plus... # 字体
|
|
|
|
|
|
|
|
textvariable=model, # 通过StringVar设置可改变的值
|
|
|
|
|
|
|
|
values=values,
|
|
|
|
|
|
|
|
bootstyle="info",# 设置下拉框的选项
|
|
|
|
|
|
|
|
).place(x=30,y=210,width=180,height=30)
|
|
|
|
|
|
|
|
ttk.Button(
|
|
|
|
|
|
|
|
root,text="生成发送端公私钥",command=client_twokey,bootstyle="default-outline"
|
|
|
|
|
|
|
|
).place(x=400, y=50, width=200, height=60)
|
|
|
|
|
|
|
|
# 创建按钮
|
|
|
|
|
|
|
|
ttk.Button(
|
|
|
|
|
|
|
|
root,text="生成数字信封文件",command=lambda: createcip(path=path.get(), op=model.get()),
|
|
|
|
|
|
|
|
bootstyle="default-outline").place(x=400,y=140,width=200,height=60)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ttk.Button(root, text="发送加密对称密钥", command=sendcipkey,
|
|
|
|
|
|
|
|
bootstyle="default-outline").place(x=400, y=230, width=200, height=60)
|
|
|
|
|
|
|
|
# 创建按钮
|
|
|
|
|
|
|
|
ttk.Button(root, text="发送加密文件", command=senddata,bootstyle="default-outline").place(x=400, y=320, width=200, height=60)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 创建按钮
|
|
|
|
|
|
|
|
ttk.Button(root, text="发送签名", command=sendsig,bootstyle="default-outline").place(x=400, y=410, width=200, height=60)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 创建按钮
|
|
|
|
|
|
|
|
ttk.Button(root, text="退出", command=root.quit,bootstyle="info").place(x=30,y=300,width=180,height=30)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 进入消息循环
|
|
|
|
|
|
|
|
root.mainloop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
init_window()
|
|
|
|
|