-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoderAndDecoder.py
More file actions
147 lines (141 loc) · 2.59 KB
/
CoderAndDecoder.py
File metadata and controls
147 lines (141 loc) · 2.59 KB
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
#encriptanddecript
from tkinter import messagebox, simpledialog, Tk
root = Tk()
Encripting_Codes = {
"Z":"d",
"Y":"i",
"X":"l",
"W":"j",
"V":"4",
"U":"w",
"T":"o",
"S":"p",
"R":"z",
"Q":"y",
"P":"3",
"O":"g",
"N":"5",
"M":"t",
"L":"x",
"K":"i",
"J":"0",
"I":"s",
"H":"q",
"G":"7",
"F":"k",
"E":"9",
"D":"f",
"C":"%",
"B":"$",
"A":"?",
"a": "8",
'b': ",",
"c": ".",
"d": "~",
"e": "2",
"f": "{",
"g": "}",
"h": "=",
'i': "_",
'j': "+",
'k': "-",
'l': ")",
'm': "(",
'n': "#",
'o': "6",
'p': "@",
'q': "*",
'r': "^",
's': ";",
't': ":",
'u': "1",
'v': "<",
'w': ">",
'x': "/",
'y': "&",
'z': '!',
' ': ' ',
}
Decripting_codes = {
"?": "A",
"$": "B",
"%": "C",
"f": "D",
"9": "E",
"k": "F",
"7": "G",
"q": "H",
"s": "I",
"0": "J",
"i": "K",
"x": "L",
"t": "M",
"5": "N",
"g": "O",
"3": "P",
"y": "Q",
"z": "R",
"p": "S",
"o": "T",
"w": "U",
"4": "V",
"j": "W",
"l": "X",
"i": "Y",
"d": "Z",
"8": "a",
",": "b",
".": "c",
"~": "d",
"2": "e",
"}": "f",
"{": "g",
"=": "h",
"_": "i",
"+": "j",
"-": "k",
")": "l",
"(": "m",
"#": "n",
"6": "o",
"@": "p",
"*": "q",
"^": "r",
";": "s",
":": "t",
"1": "u",
"<": "v",
">": "w",
"/": "x",
"&": "y",
"!": "z",
' ': " ",
}
#decript
def decript (lets_go):
Message = simpledialog.askstring('Message', 'What is your message')
Part = (" ")
for letters in (Message):
Final_Encription = (Decripting_codes.get(letters))
Final_Encription = (Part + Final_Encription)
Part = Final_Encription
messagebox.showinfo('Your decoded message is', Part)
#encript
def encript (lets_go):
Message = simpledialog.askstring('Message', 'What is your message')
Part = (" ")
for letter in (Message):
Final_Encription = (Encripting_Codes.get(letter))
Final_Encription = (Part + Final_Encription)
Part = Final_Encription
messagebox.showinfo('Your coded message is', Part)
#AskUserWhatTheyWantToDo
What_to_do = simpledialog.askstring('What do you want to do', 'What would you like to do')
def do (command):
if command == 'code':
encript ('encripting')
elif command == 'decode':
decript ('decipting')
else:
messagebox.showinfo('Error', 'Sorry I can only code and decode messages')
do (What_to_do)