-
Notifications
You must be signed in to change notification settings - Fork 0
/
encrypt3.0.pyw
96 lines (70 loc) · 1.96 KB
/
encrypt3.0.pyw
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
from Tkinter import *
root = Tk()
def main():
ans = raw_input("Do you want to encrypt or decrypt. (e/d) ")
if ans == "e":
encode()
elif ans == "d":
decode()
# Encoding
def encode():
word = text.get()
#Find length of the word
length = len(word)
start = 0
a = 0
length
#Generate encrypted word
while start < length:
letter = word[start]
convert1 = start
start = convert1 +1
#Give encode_word a value if it is first run.
if a < 1:
encode_word = ""
convert2 = a +1
a = convert2
number = ord(letter)
alg = number *2
encode_char = chr(alg)
convert4 = encode_word +encode_char
encode_word = convert4
text2.delete(0, END)
text2.insert(0,encode_word)
def decode():
word = text2.get()
#Find length of the word
length = len(word)
start = 0
a = 0
length
#Generate encrypted word
while start < length:
letter = word[start]
convert1 = start
start = convert1 +1
#Give encode_word a value if it is first run.
if a < 1:
encode_word = ""
convert2 = a +1
a = convert2
number = ord(letter)
alg = number /2
encode_char = chr(alg)
convert4 = encode_word +encode_char
encode_word = convert4
text.delete(0, END)
text.insert(0, encode_word)
label = Label(root, text="Plain Text:", justify=LEFT)
label.grid(column=1, row=1)
label2 = Label(root, text="Encrypted \nText:", justify=LEFT)
label2.grid(column=1, row=2)
text = Entry(root)
text.grid(column=2, row=1, columnspan=2)
text2 = Entry(root)
text2.grid(column=2, row=2, columnspan=2)
button = Button(root, text="Encrypt", command=encode)
button.grid(column=2, row=3, sticky=W)
button2 = Button(root, text="Decrypt", command=decode)
button2.grid(column=3, row=3)
root.mainloop()