-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathencrypt-decrypt-gui.py
54 lines (42 loc) · 1.38 KB
/
encrypt-decrypt-gui.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
# python module for one-timepad
import onetimepad
# python module to create GUI
from tkinter import *
root = Tk()
root.title("CRYPTOGRAPHY")
root.geometry("800x600")
def encryptMessage():
pt = e1.get()
# inbuilt function to encrypt a message
ct = onetimepad.encrypt(pt, 'random')
e2.insert(0, ct)
def decryptMessage():
ct1 = e3.get()
# inbuilt function to decrypt a message
pt1 = onetimepad.decrypt(ct1, 'random')
e4.insert(0, pt1)
# creating labels and positioning them on the grid
label1 = Label(root, text ='plain text')
label1.grid(row = 10, column = 1)
label2 = Label(root, text ='encrypted text')
label2.grid(row = 11, column = 1)
l3 = Label(root, text ="cipher text")
l3.grid(row = 10, column = 10)
l4 = Label(root, text ="decrypted text")
l4.grid(row = 11, column = 10)
# creating entries and positioning them on the grid
e1 = Entry(root)
e1.grid(row = 10, column = 2)
e2 = Entry(root)
e2.grid(row = 11, column = 2)
e3 = Entry(root)
e3.grid(row = 10, column = 11)
e4 = Entry(root)
e4.grid(row = 11, column = 11)
# creating encryption button to produce the output
ent = Button(root, text = "encrypt", bg ="red", fg ="white", command = encryptMessage)
ent.grid(row = 13, column = 2)
# creating decryption button to produce the output
b2 = Button(root, text = "decrypt", bg ="green", fg ="white", command = decryptMessage)
b2.grid(row = 13, column = 11)
root.mainloop()