-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencipher.py
More file actions
236 lines (184 loc) · 10.1 KB
/
Copy pathencipher.py
File metadata and controls
236 lines (184 loc) · 10.1 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
import pycipher
from tkinter import *
root = Tk()
root.title("Plaintext Encrypter")
root.iconbitmap('inkspot.ico')
plaintext = Entry(root, width=200)
plaintext.pack()
plaintext.insert(0, "Enter your text to encrypt...")
label = Label(root, text="Choose your Cipher Type:")
label.pack(anchor=W)
mainMenu = StringVar()
subMenu = StringVar()
transMenu = StringVar()
nomMenu = StringVar()
polyMenu = StringVar()
otherMenu = StringVar()
MAINOPTIONS = [("Substitution Ciphers", "Substitution"), ("Transposition Ciphers", "Transposition"), ("Nomenclature Ciphers", "Nomenclature"), ("Polyalphabetic Ciphers", "Polyalphabetic"), ("Other Ciphers", "Other")]
SUBMENU = [("Simple Substitution Cipher", "simple"), ("Atbash Cipher", "atbash"), ("Affine Cipher", "affine"), ("Playfair Cipher", "playfair"), ("Polybius Square Cipher", "polybius"), ("Baconian Cipher", "baconian"), ("Straddle Checkerboard Cipher", "checkerboard")] #baconian and straddle checkerboard not in pycipher
TRANSMENU = [("Rail-Fence Cipher", "rail-fence"), ("Columnar Transposition Cipher", "columnar"), ("ADFGVX Cipher", "adfgvx"), ("ADFGX Cipher", "adfgx"), ("Bifid Cipher", "bifid"), ("Trifid Cipher", "trifid")] # trifid cipher not in pycipher
NOMMENU = [("Nomenclature Cipher", "nomenclature"), ("Code Cipher", "code")] #neither of these are in pycipher
POLYMENU = [("Autokey Cipher", "autokey"), ("Vignere Cipher", "vignere"), ("Gronsfield Cipher", "gronsfield"), ("Beaufort Cipher", "beaufort"), ("Porta Cipher", "porta"), ("Running Key Cipher", "running key")] #running key cipher not in pycipher
OTHERMENU = [("ROT13 Cipher", "ROT13"), ("Caesar Cipher", "caesar"), ("Four-Square Cipher", "four-square"), ("Enigma M3 Cipher", "M3"), ("M-209 Cipher", "M-209"), ("Base64 Cipher", "base64"), ("Hill Cipher", "hill")] #Base64 and hill ciphers are not a part of pycipher
def calcSub(value):
#label = Label(subFrame, text = "Substitution Cipher Features Coming Soon")
#label.pack()
if subMenu.get() == "simple":
ciphertext = pycipher.SimpleSubstitution().encipher(plaintext.get())
label = Label(subFrame, text = "Simple: " + ciphertext)
label.pack(anchor=W)
if subMenu.get() == "atbash":
ciphertext = pycipher.Atbash().encipher(plaintext.get())
label = Label(subFrame, text = "Atbash: " + ciphertext)
label.pack(anchor=W)
if subMenu.get() == "affine":
a = 11 # *a* is an integer that has an inverse (mod 26), Allowable values for *a* are: 1,3,5,7,9,11,15,17,19,21,23,25
b = 15 #*b* is an integer 0-25
ciphertext = pycipher.Affine(a, b).encipher(plaintext.get())
label = Label(subFrame, text = "Affine: " + ciphertext)
label.pack(anchor=W)
if subMenu.get() == "playfair":
ciphertext = pycipher.Playfair().encipher(plaintext.get())
label = Label(subFrame, text = "Playfair: " + ciphertext)
label.pack(anchor=W)
if subMenu.get() == "polybius":
ciphertext = pycipher.PolybiusSquare().encipher(plaintext.get())
label = Label(subFrame, text = "Polybius Square: " + ciphertext)
label.pack(anchor=W)
if subMenu.get() =="baconian":
label = Label(subFrame, text = "Baconian: This feature is in the works. Check back soon.")
label.pack(anchor=W)
if subMenu.get() == "checkerboard":
label = Label(subFrame, text = "Checkerboard: This feature is in the works. Check back soon.")
label.pack(anchor=W)
def calcTrans(value):
if transMenu.get() == "rail-fence":
ciphertext = pycipher.Railfence().encipher(plaintext.get())
label = Label(transFrame, text = "Railfence: " + ciphertext)
label.pack(anchor=W)
if transMenu.get() == "columnar":
ciphertext = pycipher.ColTrans().encipher(plaintext.get())
label = Label(transFrame, text = "Columnar: " + ciphertext)
label.pack(anchor=W)
if transMenu.get() == "adfgvx":
ciphertext = pycipher.ADFGVX().encipher(plaintext.get())
label = Label(transFrame, text = "ADFGVX: " + ciphertext)
label.pack(anchor=W)
if transMenu.get() == "adfgx":
ciphertext = pycipher.ADFGX().encipher(plaintext.get())
label = Label(transFrame, text = "ADFGX: " + ciphertext)
label.pack(anchor=W)
if transMenu.get() == "bifid":
ciphertext = pycipher.Bifid().encipher(plaintext.get())
label = Label(transFrame, text = "Bifid: " + ciphertext)
label.pack(anchor=W)
if transMenu.get() == "trifid":
label = Label(transFrame, text = "Trifid: This feature is in the works. Check back soon.")
label.pack(anchor=W)
def calcNom(value):
if nomMenu.get() == "nomenclature":
label = Label(nomFrame, text = "Trifid: This feature is in the works. Check back soon.")
label.pack(anchor=W)
if nomMenu.get() == "code":
label = Label(nomFrame, text = "Trifid: This feature is in the works. Check back soon.")
label.pack(anchor=W)
label = Label(nomFrame, text = "Nomenclature Cipher Features Coming Soon")
label.pack()
def calcPoly(value):
if polyMenu.get() == "autokey":
ciphertext = pycipher.Autokey().encipher(plaintext.get())
label = Label(polyFrame, text = "Autokey: " + ciphertext)
label.pack(anchor=W)
if polyMenu.get() == "vignere":
ciphertext = pycipher.Vigenere().encipher(plaintext.get())
label = Label(polyFrame, text = "Vignere: " + ciphertext)
label.pack(anchor=W)
if polyMenu.get() == "gronsfield":
ciphertext = pycipher.Gronsfeld().encipher(plaintext.get())
label = Label(polyFrame, text = "Gronsfield: " + ciphertext)
label.pack(anchor=W)
if polyMenu.get() == "beaufort":
ciphertext = pycipher.Beaufort().encipher(plaintext.get())
label = Label(polyFrame, text = "Beaufort: " + ciphertext)
label.pack(anchor=W)
if polyMenu.get() == "porta":
ciphertext = pycipher.Porta().encipher(plaintext.get())
label = Label(polyFrame, text = "Porta: " + ciphertext)
label.pack(anchor=W)
if polyMenu.get() == "running key":
label = Label(polyFrame, text = "Running Key: This feature is in the works. Check back soon.")
label.pack(anchor=W)
def calcOther(value):
if otherMenu.get() == "ROT13":
ciphertext = pycipher.Rot13().encipher(plaintext.get())
label = Label(otherFrame, text = "ROT13: " + ciphertext)
label.pack(anchor=W)
if otherMenu.get() == "caesar":
ciphertext = pycipher.Caesar().encipher(plaintext.get())
label = Label(otherFrame, text = "Caesar: " + ciphertext)
label.pack(anchor=W)
if otherMenu.get() == "four-square":
ciphertext = pycipher.Foursquare().encipher(plaintext.get())
label = Label(otherFrame, text = "Base64: This feature is in the works. Check back soon.")
label.pack(anchor=W)
#label = Label(otherFrame, text = "Four-Square: " + ciphertext)
#label.pack(anchor=W)
if otherMenu.get() == "M3":
ciphertext = pycipher.Enigma().encipher(plaintext.get())
label = Label(otherFrame, text = "Enigma M3: " + ciphertext)
label.pack(anchor=W)
if otherMenu.get() == "M-209":
ciphertext = pycipher.M209().encipher(plaintext.get())
label = Label(otherFrame, text = "M-209: " + ciphertext)
label.pack(anchor=W)
if otherMenu.get() == "base64":
label = Label(otherFrame, text = "Base64: This feature is in the works. Check back soon.")
label.pack(anchor=W)
if otherMenu.get() == "hill":
label = Label(otherFrame, text = "Hill: This feature is in the works. Check back soon.")
label.pack(anchor=W)
def submitMain(value):
global subFrame, transFrame, nomFrame, polyFrame, otherFrame
top = Toplevel()
top.title(mainMenu.get())
top.iconbitmap('inkspot.ico')
subFrame = LabelFrame(top)
transFrame = LabelFrame(top)
nomFrame = LabelFrame(top)
polyFrame = LabelFrame(top)
otherFrame = LabelFrame(top)
if mainMenu.get().lower() == "substitution":
for text, cipher in SUBMENU:
Radiobutton(top, text=text, variable=subMenu, value=cipher).pack(anchor=W)
button = Button(top, text="Calculate CipherText", command=lambda: calcSub(subMenu.get()))
button.pack()
subFrame.pack()
if mainMenu.get().lower() == "transposition":
for text, cipher in TRANSMENU:
Radiobutton(top, text=text, variable=transMenu, value=cipher).pack(anchor=W)
button = Button(top, text="Calculate CipherText", command=lambda: calcTrans(transMenu.get()))
button.pack()
transFrame.pack()
if mainMenu.get().lower() == "nomenclature":
for text, cipher in NOMMENU:
Radiobutton(top, text=text, variable=nomMenu, value=cipher, state='disabled').pack(anchor=W)
button = Button(top, text="Calculate CipherText", command=lambda: calcNom(nomMenu.get()))
button.pack()
nomFrame.pack()
if mainMenu.get().lower() == "polyalphabetic":
for text, cipher in POLYMENU:
Radiobutton(top, text=text, variable=polyMenu, value=cipher).pack(anchor=W)
button = Button(top, text="Calculate CipherText", command=lambda: calcPoly(polyMenu.get()))
button.pack()
polyFrame.pack()
if mainMenu.get().lower() == "other":
for text, cipher in OTHERMENU:
Radiobutton(top, text=text, variable=otherMenu, value=cipher).pack(anchor=W)
button = Button(top, text="Calculate CipherText", command=lambda: calcOther(otherMenu.get()))
button.pack()
otherFrame.pack()
for text, cipher in MAINOPTIONS:
Radiobutton(root, text=text, variable=mainMenu, value=cipher).pack(anchor=W)
button = Button(root, text="Submit", command=lambda: submitMain(mainMenu.get()))
button.pack()
root.mainloop()