coding utf-8 from Tkinter import from tkFileDialog import import paszi

 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# coding=utf-8
from Tkinter import *
from tkFileDialog import *
import paszi
import tkMessageBox
root = Tk()
root.title('RSA program')
root.minsize(400, 400)
root.maxsize(400, 400)
I_Frame = Frame(root, height=80)
II_Frame = Frame(root, height=80, width=60)
III_Frame = Frame(root, height=80, width=60)
IV_Frame = Frame(root, height=80, width=60)
V_Frame = Frame(root, height=80, width=60)
I_Frame.pack(side='top', fill='x')
II_Frame.pack(side='top', fill='x')
III_Frame.pack(side='top', fill='x')
IV_Frame.pack(side='top', fill='x')
V_Frame.pack(side='top', fill='x')
I_Label = Label(IV_Frame, text=u"Что вы хотите сделать с файлом?", font="Arial 15")
II_Label = Label(II_Frame, text=u"Введите ключ")
I_Enter = Entry(I_Frame, font="Arial 12")
II_Enter = Entry(II_Frame, font="Arial 12")
I_Label.pack()
II_Label.place(x=250, y=20, width=140, height=30)
I_Enter.place(x=10, y=20, width=220, height=30)
II_Enter.place(x=10, y=20, width=220, height=30)
loadBtn = Button(I_Frame, text=u'Загрузить файл')
encBtn = Button(V_Frame, text=u'Зашифровать')
decBtn = Button(V_Frame, text=u'Расшифровать')
filename = ''
FileNameVar = StringVar()
I_Enter['textvariable'] = FileNameVar
open_key = ''
OpenKeyVar = StringVar()
II_Enter['textvariable'] = OpenKeyVar
def openfile():
global filename
filename = askopenfilename()
FileNameVar.set(filename)
F = paszi.gen_f
N = paszi.gen_n
def encrypt_file():
global filename
paszi.encrypt(filename, OpenKeyVar.get(), N)
'''
try:
if (int(open_key) < F) & (int(F) % int(open_key) != 0):
paszi.encrypt(filename, open_key, N)
except Exception:
tkMessageBox.showinfo("ERROR", "Wrong open key ")
except ValueError:
tkMessageBox.showinfo("ERROR", "Это не число ")
'''
def decrypt_file():
global filename
paszi.decrypt(filename, 9421, 13843)
#tkMessageBox.showinfo("Decrypt", "It's OK")
loadBtn.place(x=250, y=20, width=140, height=30)
encBtn.place(x=10, y=20, wid=140, height=30)
decBtn.place(x=250, y=20, width=140, height=30)
loadBtn['command'] = openfile
encBtn['command'] = encrypt_file
decBtn['command'] = decrypt_file
root.mainloop()