-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
50 lines (44 loc) · 1.77 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import tkinter.filedialog as filedialog
import tkinter as tk
from fancyDES.fancyDES import FancyDES
import binascii
class Application(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.labelVar = tk.StringVar()
self.outputVar = tk.StringVar()
self.pack()
self.create_widgets()
def create_widgets(self):
self.find_file = tk.Button(self, text="Find File", command=self.find_file_event)
self.find_file.pack(side="top")
self.password = tk.Entry(self, show="*")
self.password.pack()
self.encrypt = tk.Button(self, text="Encrypt", command = self.encrypt_data)
self.encrypt.pack()
self.labelFile = tk.Label(self, textvariable = self.labelVar, relief = tk.RAISED)
self.labelFile.pack()
self.quit = tk.Button(self, text="QUIT", fg="red", command=self.master.destroy)
self.quit.pack(side="bottom")
self.outputMessage = tk.Label(self, textvariable = self.outputVar, relief = tk.RAISED)
self.outputMessage.pack(side="bottom")
def find_file_event(self):
self.filename = filedialog.askopenfilename()
self.labelVar.set("Filename {}".format(self.filename))
print(self.filename)
def encrypt_data(self):
filename = self.filename
passwd = self.password.get()
if (filename is not None) and (passwd is not None):
MODE = "OFB"
fancyDES = FancyDES(
path=filename, key=passwd, fromFile=True
)
cipher = fancyDES.generate_cipher(mode=MODE)
result = binascii.hexlify(cipher)
self.outputVar.set(result)
print(len(cipher))
root = tk.Tk()
app = Application(master=root)
app.mainloop()