This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appGUI.py
155 lines (122 loc) · 4.35 KB
/
appGUI.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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# this was one of the learning projects
# i've found useful for starting Tkinter
# and for understanding concept of message encryption in a very very simple version..
# NB-NOTE: THE ORIGINAL PROJECT
# CAN BE FOUND IN THE FOLLOWING ADDRESS:
# https://www.geeksforgeeks.org/python-message-encode-decode-using-tkinter/
# This Project is redesigned and updated in a more understandable way
# by me! (/https://github.com/AmirHosseinRnj1)
# If you have any problem running or understanding this project,
# feel free to make contact with me...
#TKINTER MODULE SETUP
#import tkinter module
from tkinter import *
import random
import time
import datetime
from EnDeCoder import encode,decode
###################
###CREATING GUI####
###################
#creating root object
from tkinter import Label
root = Tk()
#defining size of window
root.geometry("1200x6000")
#defining title
root.title("Message Encryption And Decryption")
#creating frames
Tops = Frame(root,width=1600,relief=SUNKEN)
Tops.pack(side=TOP)
f1 = Frame(root,width=800,height=700,relief=SUNKEN)
f1.pack(side=LEFT)
######################
####TIME AND LABELS####
######################
localtime = time.asctime(time.localtime(time.time()))
#initialize_Parameters
rand = StringVar()
Msg = StringVar()
Key = StringVar()
Mode = StringVar()
Result = StringVar()
#making labels for created frames
lblinfo = Label(Tops,font=('helvetica',50,'bold'),
text="SECRET MESSAGING \n Vigenère cipher",
fg="Black",bd=10,anchor="w")
lblinfo.grid(row=0,column=0)
lblinfo = Label(Tops,font=('Arial',25,'bold'),
text=localtime,
fg="Steel Blue",bd=10,anchor='w')
lblinfo.grid(row=1,column=0)
lblReference = Label(f1,font=('arial',16,'bold'),
text="Name",bd=16,anchor='w')
lblReference.grid(row=0,column=0)
txtReference = Entry(f1,font=('arial',16,'bold'),
textvariable=rand,bd=10,insertwidth=4,
bg='Powder Blue',justify="center")
txtReference.grid(row=0,column=1)
lblMsg = Label(f1,font=('arial',16,'bold'),
text="Message",bd=16,anchor='w')
lblMsg.grid(row=1,column=0)
txtMsg = Entry(f1,font=('arial',16,'bold'),
textvariable=Msg,bd=10,insertwidth=4,
bg="Powder Blue",justify="center")
txtMsg.grid(row=1,column=1)
lblKey = Label(f1,font=('arial',16,'bold'),
text="Key",bd=16,anchor='w')
lblKey.grid(row=2,column=0)
txtKey = Entry(f1,font=('arial',16,'bold'),
textvariable=Key,bd=10,insertwidth=4,
bg="Powder Blue",justify="center")
txtKey.grid(row=2,column=1)
lblMode = Label(f1,font=('arial',16,'bold'),
text="Choose Mode : (E) for Encryption or (D) for Decryption",bd=16,anchor='w')
lblMode.grid(row=3,column=0)
txtMode = Entry(f1,font=('arial',16,'bold'),
textvariable=Mode,bd=10,insertwidth=4,
bg="Powder Blue",justify="center")
txtMode.grid(row=3,column=1)
lblService = Label(f1,font=('arial',16,'bold'),
text="The Result",bd=16,anchor='w')
lblService.grid(row=2,column=2)
txtService = Entry(f1,font=('arial',16,'bold'),
textvariable=Result,bd=10,insertwidth=4,
bg="Powder Blue",justify="center")
txtService.grid(row=2,column=3)
########################
####INITIALIZED FUN####
########################
def exit():
root.destroy()
def reset():
rand.set("")
Msg.set("")
Key.set("")
Mode.set("")
Result.set("")
def Ref():
clear = txtMsg.get()
key = txtKey.get()
mode = txtMode.get()
try:
if mode == "e":
Result.set(encode(key,clear))
elif mode == "d":
Result.set(decode(key,clear))
except:
print("Bad Input, Plz Give e for Encode and d for Decode")
reset()
btnShow = Button(f1,padx=16,pady=8,bd=16,fg="black",
font=('Arial',16,'bold'),width=10,
text="Show Result",bg="powder blue",
command=Ref).grid(row=7,column=1)
btnReset = Button(f1,padx=16,pady=8,bd=16,fg="black",
font=('Arial',16,'bold'),width=10,
text="Reset",bg="green",
command=reset).grid(row=7,column=2)
btnExit = Button(f1,padx=16,pady=8,bd=16,fg="black",
font=('Arial',16,'bold'),width=10,
text="Exit",bg="Red",
command=exit).grid(row=7,column=3)
root.mainloop()