我想调用python的第三方库来对文件进行加密解密,目前在制作这个系统的图形界面。整个代码我放在了三个py文件中,但要怎么调用呢?
下面是主代码:
#coding=utf-8
from tkinter import *
from tkinter.messagebox import *
from encrypt_1 import *
from decode_2 import *
root = Tk()
root.title("文件加密解密")
root.geometry("450x300")
#文件加密系统
def encrypt():
showinfo("加密系统","欢迎进入文件加密系统!",command=encrypt_1)
#文件解密系统
def decode():
showinfo("解密系统","欢迎进入文件解密系统!")
aLabel = Label(root,text='欢迎进入文件加密解密系统!',font='楷书 20',width=30,height=5,fg='red')
aLabel.place(x=20,y=10)
#加密系统
c1=Button(root,text='加密文件',font ='20',height=2,width=25,command=encrypt)
c1.place(x=80,y=150)
#解密系统
c1=Button(root,text='文件解密',font ='20',height=2,width=25,command=decode)
c1.place(x=80,y=200)
root.mainloop()
然后还有一个加密模块和解密模块,暂时不考虑解密模块,加密模块的代码如下:
#coding=utf-8
from tkinter import *
from tkinter.messagebox import *
from tkinter import filedialog
#验证加密时两次密码是否输入一致
def verify():
if(E2.get()==E3.get()):
showinfo("加密成功!")
else:
showinfo("密码请输入一致!")
#浏览本地文件
def file_view():
root.withdraw()
file_select = filedialog.askopenfilename()
root = Tk()
root.title("文件加密")
root.geometry("450x300")
L1 = Label(root,text="选择文件:")
L1.place(x=10,y=10)
E1 = Entry(root,bd =5,font=12,width=15)
E1.place(x=80,y=10)
B1 = Button(root,text="浏览",width=15,command=file_view)
B1.place(x=250,y=10)
L2 = Label(root,text="密 码:")
L2.place(x=10,y=60)
E2 = Entry(root,bd =5,font=12,width=15,show = "*")
E2.place(x=80,y=60)
L3 = Label(root,text="密码确认:")
L3.place(x=10,y=110)
E3 = Entry(root,bd =5,font=12,width=15,show = "*")
E3.place(x=80,y=110)
B2 = Button(root,text="加密文件",width=15,command=verify)
B2.place(x=100,y=150)
现在主要问题就是:
1.如何调用加密模块的内容
2.加密模块中浏览本地文件怎么打开,或者把浏览中选择的文件路径填到E1的文本框中
谢谢大家了!