-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPadlock.py
3356 lines (2693 loc) · 167 KB
/
Padlock.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
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
"""
Padlock Encryption Software
Copyright 2019
Created by: Suraj Kothari
For A-level Computer Science
at Woodhouse College.
"""
import multicrypt
from PIL import Image, ImageTk
import tkinter as tk
import tkinter.ttk
import tkinter.filedialog
import os
import time
import threading
from styles import *
class Padlock(tk.Tk):
"""The main application class that manages the individual frames"""
def __init__(self):
tk.Tk.__init__(self)
self.iconbitmap("Images/Padlock icon.ico") # Icon in title bar
self.title("Padlock Encryption Software")
self.geometry("1100x600") # Default application window size
# Doesn't allow the application to resize below the given resolution
self.minsize(1100, 600)
"""Makes the application responsive when resizing"""
top = self.winfo_toplevel() # Gets the top level window to resize
# Makes the rows and columns of the window responsive by scale factor 1
top.columnconfigure(0, weight=1)
top.rowconfigure(0, weight=1)
top.rowconfigure(1, weight=1)
self.configure(background=Colours.WHITE)
"""Creates a footer"""
footer = tk.Frame(self, bg=Colours.FOOTER)
self.copyrightMessage = "Copyright 2019 - Padlock Encryption Software. \
Created by: Suraj Kothari. For A-level Computer Science at Woodhouse College."
copyrightText = tk.Label(footer, text=self.copyrightMessage,
bg=Colours.FOOTER, fg=Colours.WHITE, font=Fonts.SMALL_PRINT)
footer.grid(row=2, sticky="ew")
copyrightText.grid()
self._frame = None # Clears the current frame
# Sets the current frame to the home page
self.switch_frame(HomePage)
# self.switch_frame(EncryptMenu, process="Encrypt", dataFormat="Messages", cipher="RC4 Cipher")
def switch_frame(self, frame_class, process=None, dataFormat=None, cipher=None, cipherMode=None):
"""Destroys current frame and replaces it with a new one."""
"""
By default, all extra necessary arguments are passed to all classes,
even if they don't require it. This removes the need to check
which class needs individual extra arguments.
"""
new_frame = frame_class(self, process, dataFormat, cipher, cipherMode)
# Check if the current frame exists, then destroy it
if self._frame is not None:
self._frame.destroy()
self._frame = new_frame
# Position the individual frames on the first row (above the footer)
self._frame.grid(row=1, sticky="n")
class HomePage(tk.Frame):
"""Creates the home page frame"""
def __init__(self, master, process, dataFormat, cipher, cipherMode):
tk.Frame.__init__(self, master)
self.configure(background=Colours.WHITE)
# Initialises the icons used for this frame
self.icon = Image.open("Images/encryptIcon.png")
self.icon2 = Image.open("Images/decryptIcon.png")
# Makes the icon able to be used by widgets with these references
self.ENCRYPT_ICON = ImageTk.PhotoImage(self.icon)
self.DECRYPT_ICON = ImageTk.PhotoImage(self.icon2)
self.createWidgets()
def createWidgets(self):
self.master = self.winfo_toplevel() # Gets the top level window
"""
Creates a header:
The header frame is placed in the main application (master frame),
separate from the current frame.
"""
self.header = tk.Frame(self.master, bg=Colours.MAIN)
self.Logo = tk.Label(self.header, text="Padlock", bg=Colours.MAIN,
fg=Colours.LOGO, font=Fonts.LOGO)
self.homeTag = tk.Label(self.header, text="Home", bg=Colours.WHITE,
fg=Colours.FOREGROUND, font=Fonts.TAGS)
self.header.grid(row=0, sticky="new")
self.Logo.grid(padx=20, pady=20)
self.homeTag.grid(column=1, row=0, sticky="ns", ipadx=40, pady=(10, 0))
self.encryptButton = tk.Button(self, text="Encrypt", compound="left", image=self.ENCRYPT_ICON,
command=lambda: self.master.switch_frame(FormatSelctionMenu, process="Encrypt"),
**ButtonStyle.ENCRYPT_BUTTON)
self.verticalSeparator = tk.ttk.Separator(self, orient="vertical")
self.decryptButton = tk.Button(self, text="Decrypt", compound="left", image=self.DECRYPT_ICON,
command=lambda: self.master.switch_frame(FormatSelctionMenu, process="Decrypt"),
**ButtonStyle.DECRYPT_BUTTON)
# Keeps an extra reference to the image objects
self.encryptButton.image = self.ENCRYPT_ICON
self.decryptButton.image = self.DECRYPT_ICON
self.encryptButton.grid(padx=26)
self.verticalSeparator.grid(column=1, row=0, rowspan=1, sticky="ns")
self.decryptButton.grid(column=2, row=0, padx=26)
# Creates hover listeners for the buttons to change colour when hovered
self.encryptButton.bind("<Enter>", lambda e: self.encryptButton.configure(
bg=ButtonStyle.ENCRYPT_BUTTON["activebackground"]))
self.encryptButton.bind("<Leave>", lambda e: self.encryptButton.configure(
bg=ButtonStyle.ENCRYPT_BUTTON["bg"]))
self.decryptButton.bind("<Enter>", lambda e: self.decryptButton.configure(
bg=ButtonStyle.DECRYPT_BUTTON["activebackground"]))
self.decryptButton.bind("<Leave>", lambda e: self.decryptButton.configure(
bg=ButtonStyle.DECRYPT_BUTTON["bg"]))
class FormatSelctionMenu(tk.Frame):
"""Creates the data format selection page frame"""
def __init__(self, master, process, dataFormat, cipher, cipherMode):
tk.Frame.__init__(self, master)
self.process = process
# Initialises the icons used in this frame
self.icon = Image.open("Images/messageIcon.png")
self.icon2 = Image.open("Images/fileIcon.png")
self.icon3 = Image.open("Images/imageIcon.png")
# Makes the icon able to be used by widgets with these references
self.MESSAGE_ICON = ImageTk.PhotoImage(self.icon)
self.FILE_ICON = ImageTk.PhotoImage(self.icon2)
self.IMAGE_ICON = ImageTk.PhotoImage(self.icon3)
self.configure(background=Colours.WHITE)
self.createWidgets()
def createWidgets(self):
self.master = self.winfo_toplevel() # Gets the top level window
"""
Creates a header:
The header frame is placed in the main application (master frame),
separate from the current frame.
"""
self.header = tk.Frame(self.master, bg=Colours.MAIN)
self.Logo = tk.Label(self.header, text="Padlock", bg=Colours.MAIN,
fg=Colours.LOGO, font=Fonts.LOGO)
self.homeTag = tk.Label(self.header, text="Home", bg=Colours.MAIN,
fg=Colours.TAGS_NOT_ACTIVE, font=Fonts.TAGS, cursor="hand2")
self.sectionTag = tk.Label(self.header, text=self.process,
bg=Colours.WHITE, fg=Colours.FOREGROUND, font=Fonts.TAGS)
self.header.grid(row=0, sticky="new")
self.Logo.grid(padx=20, pady=20)
self.homeTag.grid(column=1, row=0, padx=10, pady=(10, 0))
self.sectionTag.grid(column=2, row=0, sticky="ns", ipadx=40,
padx=10, pady=(10, 0))
# Adds an event handler for the tag to act like a link when clicked
self.homeTag.bind("<Button-1>", lambda e: self.master.switch_frame(HomePage))
self.messageButton = tk.Button(self, text="Messages", compound="left", image=self.MESSAGE_ICON,
command=lambda: self.master.switch_frame(CipherMenu, process=self.process, dataFormat="Messages"),
**ButtonStyle.MESSAGE_BUTTON)
self.verticalSeparator = tk.ttk.Separator(self, orient="vertical")
self.fileButton = tk.Button(self, text="Files", compound="left", image=self.FILE_ICON,
command=lambda: self.master.switch_frame(CipherMenu, process=self.process, dataFormat="Files"),
**ButtonStyle.FILE_BUTTON)
self.verticalSeparator2 = tk.ttk.Separator(self, orient="vertical")
self.imageButton = tk.Button(self, text="Images", compound="left", image=self.IMAGE_ICON,
command=lambda: self.master.switch_frame(CipherMenu, process=self.process, dataFormat="Images"),
**ButtonStyle.IMAGE_BUTTON)
self.messageButton.grid(padx=26)
self.verticalSeparator.grid(column=1, row=0, rowspan=1, sticky="ns")
self.fileButton.grid(column=2, row=0, padx=26)
self.verticalSeparator2.grid(column=3, row=0, rowspan=1, sticky="ns")
self.imageButton.grid(column=4, row=0, padx=26)
# Creates hover listeners for the buttons to change colour when hovered
self.messageButton.bind("<Enter>", lambda e: self.messageButton.configure(
bg=ButtonStyle.MESSAGE_BUTTON["activebackground"]))
self.messageButton.bind("<Leave>", lambda e: self.messageButton.configure(
bg=ButtonStyle.MESSAGE_BUTTON["bg"]))
self.fileButton.bind("<Enter>", lambda e: self.fileButton.configure(
bg=ButtonStyle.FILE_BUTTON["activebackground"]))
self.fileButton.bind("<Leave>", lambda e: self.fileButton.configure(
bg=ButtonStyle.FILE_BUTTON["bg"]))
self.imageButton.bind("<Enter>", lambda e: self.imageButton.configure(
bg=ButtonStyle.IMAGE_BUTTON["activebackground"]))
self.imageButton.bind("<Leave>", lambda e: self.imageButton.configure(
bg=ButtonStyle.IMAGE_BUTTON["bg"]))
class CipherMenu(tk.Frame):
"""Creates the cipher selection page frame"""
def __init__(self, master, process, dataFormat, cipher, cipherMode):
tk.Frame.__init__(self, master)
self.process = process
self.dataFormat = dataFormat
self.configure(background=Colours.WHITE)
self.createWidgets()
def createWidgets(self):
self.master = self.winfo_toplevel() # Gets the top level window
"""
Creates a header:
The header frame is placed in the main application (master frame),
separate from the current frame.
"""
self.header = tk.Frame(self.master, bg=Colours.MAIN)
self.Logo = tk.Label(self.header, text="Padlock", bg=Colours.MAIN, fg=Colours.LOGO, font=Fonts.LOGO)
self.homeTag = tk.Label(self.header, text="Home", bg=Colours.MAIN, fg=Colours.TAGS_NOT_ACTIVE,
font=Fonts.TAGS, cursor="hand2")
self.sectionTag = tk.Label(self.header, text=self.process, bg=Colours.MAIN, fg=Colours.TAGS_NOT_ACTIVE,
font=Fonts.TAGS, cursor="hand2")
self.sectionTag2 = tk.Label(self.header, text=self.dataFormat, bg=Colours.WHITE, fg=Colours.FOREGROUND,
font=Fonts.TAGS)
self.header.grid(row=0, sticky="new")
self.Logo.grid(padx=20, pady=20)
self.homeTag.grid(column=1, row=0, padx=10, pady=(10, 0))
self.sectionTag.grid(column=2, row=0, pady=(10, 0), padx=10)
self.sectionTag2.grid(column=3, row=0, sticky="ns", ipadx=40, pady=(10, 0), padx=10)
# Adds an event handler for the tag to act like a link when clicked
self.homeTag.bind("<Button-1>", lambda e: self.master.switch_frame(HomePage))
self.sectionTag.bind("<Button-1>", lambda e: self.master.switch_frame(FormatSelctionMenu, process=self.process))
if self.dataFormat == "Images":
# If an image format is chosen, the button will go directly to the encrypt/decrypt menu. Mode selection is ignored.
self.caesar_Button = tk.Button(self, text="Caesar",
command=lambda: self.master.switch_frame(EncryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher="Caesar Cipher")
if self.process == "Encrypt" else \
self.master.switch_frame(DecryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher="Caesar Cipher"), **ButtonStyle.CAESAR_BUTTON)
self.vigenere_Button = tk.Button(self, text="Vigenere",
command=lambda: self.master.switch_frame(EncryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher="Vigenere Cipher")
if self.process == "Encrypt" else \
self.master.switch_frame(DecryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher="Vigenere Cipher"), **ButtonStyle.VIGENERE_BUTTON)
else:
self.caesar_Button = tk.Button(self, text="Caesar",
command=lambda: self.master.switch_frame(CipherModeMenu, process=self.process,
dataFormat=self.dataFormat, cipher="Caesar Cipher"), **ButtonStyle.CAESAR_BUTTON)
self.vigenere_Button = tk.Button(self, text="Vigenere",
command=lambda: self.master.switch_frame(CipherModeMenu, process=self.process,
dataFormat=self.dataFormat, cipher="Vigenere Cipher"), **ButtonStyle.VIGENERE_BUTTON)
if self.dataFormat == "Files":
self.DES_Button = tk.Button(self, text="DES",
command=lambda: self.master.switch_frame(CipherModeMenu, process=self.process,
dataFormat=self.dataFormat, cipher="DES Cipher"), **ButtonStyle.DES_BUTTON)
self.triple_DES_Button = tk.Button(self, text="Triple DES",
command=lambda: self.master.switch_frame(CipherModeMenu, process=self.process,
dataFormat=self.dataFormat, cipher="Triple DES Cipher"), **ButtonStyle.TRIPLE_DES_BUTTON)
self.AES_Button = tk.Button(self, text="AES",
command=lambda: self.master.switch_frame(CipherModeMenu, process=self.process,
dataFormat=self.dataFormat, cipher="AES Cipher"), **ButtonStyle.AES_BUTTON)
self.RC4_Button = tk.Button(self, text="RC4",
command=lambda: self.master.switch_frame(CipherModeMenu, process=self.process,
dataFormat=self.dataFormat, cipher="RC4 Cipher"), **ButtonStyle.RC4_BUTTON)
else:
self.DES_Button = tk.Button(self, text="DES",
command=lambda: self.master.switch_frame(EncryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher="DES Cipher")
if self.process == "Encrypt" else \
self.master.switch_frame(DecryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher="DES Cipher"), **ButtonStyle.DES_BUTTON)
self.triple_DES_Button = tk.Button(self, text="Triple DES",
command=lambda: self.master.switch_frame(EncryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher="Triple DES Cipher")
if self.process == "Encrypt" else \
self.master.switch_frame(DecryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher="Triple DES Cipher"), **ButtonStyle.TRIPLE_DES_BUTTON)
self.AES_Button = tk.Button(self, text="AES",
command=lambda: self.master.switch_frame(EncryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher="AES Cipher")
if self.process == "Encrypt" else \
self.master.switch_frame(DecryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher="AES Cipher"), **ButtonStyle.AES_BUTTON)
self.RC4_Button = tk.Button(self, text="RC4",
command=lambda: self.master.switch_frame(EncryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher="RC4 Cipher")
if self.process == "Encrypt" else \
self.master.switch_frame(DecryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher="RC4 Cipher"), **ButtonStyle.RC4_BUTTON)
self.verticalSeparator = tk.ttk.Separator(self, orient="vertical")
self.verticalSeparator2 = tk.ttk.Separator(self, orient="vertical")
self.weakText = tk.Label(self, text="WEAK CIPHERS", bg=Colours.WHITE,
fg=Colours.INFO, font=Fonts.INFO)
self.medText = tk.Label(self, text="MEDIUM CIPHERS", bg=Colours.WHITE,
fg=Colours.INFO, font=Fonts.INFO)
self.strongText = tk.Label(self, text="STRONG CIPHERS", bg=Colours.WHITE,
fg=Colours.INFO, font=Fonts.INFO)
self.weakText.grid(row=0, column=0, padx=26, pady=(0, 5))
self.caesar_Button.grid(row=1, column=0, padx=26, pady=(0, 10))
self.vigenere_Button.grid(row=2, column=0, padx=26, pady=(10, 0))
self.verticalSeparator.grid(column=1, row=1, rowspan=2, sticky="ns")
self.medText.grid(column=2, row=0, padx=26, pady=(0, 5))
self.DES_Button.grid(column=2, row=1, padx=26, pady=(0, 10))
self.triple_DES_Button.grid(column=2, row=2, padx=26, pady=(10, 0))
self.verticalSeparator2.grid(column=3, row=1, rowspan=2, sticky="ns")
self.strongText.grid(column=4, row=0, padx=26, pady=(0, 5))
self.AES_Button.grid(column=4, row=1, padx=26, pady=(0, 10))
self.RC4_Button.grid(column=4, row=2, padx=26, pady=(10, 0))
# Creates hover listeners for the buttons to change colour when hovered
self.caesar_Button.bind("<Enter>", lambda e: self.caesar_Button.configure(
bg=ButtonStyle.CAESAR_BUTTON["activebackground"]))
self.caesar_Button.bind("<Leave>", lambda e: self.caesar_Button.configure(
bg=ButtonStyle.CAESAR_BUTTON["bg"]))
self.vigenere_Button.bind("<Enter>", lambda e: self.vigenere_Button.configure(
bg=ButtonStyle.VIGENERE_BUTTON["activebackground"]))
self.vigenere_Button.bind("<Leave>", lambda e: self.vigenere_Button.configure(
bg=ButtonStyle.VIGENERE_BUTTON["bg"]))
self.DES_Button.bind("<Enter>", lambda e: self.DES_Button.configure(
bg=ButtonStyle.DES_BUTTON["activebackground"]))
self.DES_Button.bind("<Leave>", lambda e: self.DES_Button.configure(
bg=ButtonStyle.DES_BUTTON["bg"]))
self.triple_DES_Button.bind("<Enter>", lambda e: self.triple_DES_Button.configure(
bg=ButtonStyle.TRIPLE_DES_BUTTON["activebackground"]))
self.triple_DES_Button.bind("<Leave>", lambda e: self.triple_DES_Button.configure(
bg=ButtonStyle.TRIPLE_DES_BUTTON["bg"]))
self.AES_Button.bind("<Enter>", lambda e: self.AES_Button.configure(
bg=ButtonStyle.AES_BUTTON["activebackground"]))
self.AES_Button.bind("<Leave>", lambda e: self.AES_Button.configure(
bg=ButtonStyle.AES_BUTTON["bg"]))
self.RC4_Button.bind("<Enter>", lambda e: self.RC4_Button.configure(
bg=ButtonStyle.RC4_BUTTON["activebackground"]))
self.RC4_Button.bind("<Leave>", lambda e: self.RC4_Button.configure(
bg=ButtonStyle.RC4_BUTTON["bg"]))
class CipherModeMenu(tk.Frame):
"""Creates the mode selection page frame"""
"""Creates the cipher selection page frame"""
def __init__(self, master, process, dataFormat, cipher, cipherMode):
tk.Frame.__init__(self, master)
self.process = process
self.dataFormat = dataFormat
self.cipher = cipher
self.cipherMode = cipherMode
self.configure(background=Colours.WHITE)
self.createWidgets()
def createWidgets(self):
self.master = self.winfo_toplevel() # Gets the top level window
if self.process == "Encrypt":
self.placeholder = "encrypt"
else:
self.placeholder = "decrypt"
if self.dataFormat == "Messages":
self.classic_text = "Uses the English Alphabet. This will NOT " + self.placeholder + " ASCII characters, \
such as punctuation and numbers."
self.ascii_text = "This will " + self.placeholder + " ASCII characters such as punctuation and numbers."
else:
self.classic_text = "Uses the English Alphabet. This will NOT " + self.placeholder + " ASCII characters, \
such as punctuation and numbers. Use this mode just for text files."
self.classic_text2 = self.placeholder.title() + "s normally with the cipher. Use this mode for just text files."
self.ascii_text = "This will " + self.placeholder + " ASCII characters such as punctuation and numbers. \
Use this mode just for text files."
self.base64_text = "Uses Base64 to encode files before " + self.placeholder + "ing them. \
Use this mode for files of any type."
"""
Creates a header:
The header frame is placed in the main application (master frame),
separate from the current frame.
"""
self.header = tk.Frame(self.master, bg=Colours.MAIN)
self.Logo = tk.Label(self.header, text="Padlock", bg=Colours.MAIN, fg=Colours.LOGO, font=Fonts.LOGO)
self.homeTag = tk.Label(self.header, text="Home", bg=Colours.MAIN, fg=Colours.TAGS_NOT_ACTIVE,
font=Fonts.TAGS, cursor="hand2")
self.sectionTag = tk.Label(self.header, text=self.process, bg=Colours.MAIN, fg=Colours.TAGS_NOT_ACTIVE,
font=Fonts.TAGS, cursor="hand2")
self.sectionTag2 = tk.Label(self.header, text=self.dataFormat, bg=Colours.MAIN, fg=Colours.TAGS_NOT_ACTIVE,
font=Fonts.TAGS, cursor="hand2")
self.sectionTag3 = tk.Label(self.header, text="Mode Select", bg=Colours.WHITE, fg=Colours.FOREGROUND,
font=Fonts.TAGS)
self.header.grid(row=0, sticky="new")
self.Logo.grid(padx=20, pady=20)
self.homeTag.grid(column=1, row=0, padx=10, pady=(10, 0))
self.sectionTag.grid(column=2, row=0, pady=(10, 0), padx=10)
self.sectionTag2.grid(column=3, row=0, pady=(10, 0), padx=10)
self.sectionTag3.grid(column=4, row=0, sticky="ns", ipadx=40, pady=(10, 0), padx=10)
# Adds an event handler for the tag to act like a link when clicked
self.homeTag.bind("<Button-1>", lambda e: self.master.switch_frame(HomePage))
self.sectionTag.bind("<Button-1>", lambda e: self.master.switch_frame(FormatSelctionMenu, process=self.process))
self.sectionTag2.bind("<Button-1>", lambda e: self.master.switch_frame(CipherMenu, process=self.process,
dataFormat=self.dataFormat))
# If chosen format is files and either DES or Triple DES is selected, create these widgets
if self.dataFormat == "Files" and self.cipher in ("DES Cipher", "Triple DES Cipher", "AES Cipher", "RC4 Cipher"):
self.classicButton = tk.Button(self, text="Classic",
command=lambda: self.master.switch_frame(EncryptMenu, process=self.process, dataFormat=self.dataFormat,
cipher=self.cipher, cipherMode="Classic")
if self.process == "Encrypt" else \
self.master.switch_frame(DecryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher=self.cipher, cipherMode="Classic"), **ButtonStyle.CLASSIC_BUTTON)
self.classicText = tk.Label(self, text=self.classic_text2, wraplength=220, bg=Colours.WHITE,
fg=Colours.INFO, font=Fonts.INFO)
self.verticalSeparator = tk.ttk.Separator(self, orient="vertical")
self.base64Button = tk.Button(self, text="Base64",
command=lambda: self.master.switch_frame(EncryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher=self.cipher, cipherMode="Base64")
if self.process == "Encrypt" else \
self.master.switch_frame(DecryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher=self.cipher, cipherMode="Base64"), **ButtonStyle.BASE64_BUTTON)
self.Base64_Text = tk.Label(self, text=self.base64_text, bg=Colours.WHITE,
wraplength=220, fg=Colours.INFO, font=Fonts.INFO)
self.classicButton.grid(padx=20)
self.classicText.grid(row=1, padx=20, pady=10)
self.verticalSeparator.grid(column=1, row=0, rowspan=1, sticky="ns")
self.base64Button.grid(column=2, row=0, padx=20)
self.Base64_Text.grid(column=2, row=1, padx=20, pady=10)
# Creates hover listeners for the buttons to change colour when hovered
self.classicButton.bind("<Enter>", lambda e: self.classicButton.configure(
bg=ButtonStyle.CLASSIC_BUTTON["activebackground"]))
self.classicButton.bind("<Leave>", lambda e: self.classicButton.configure(
bg=ButtonStyle.CLASSIC_BUTTON["bg"]))
self.base64Button.bind("<Enter>", lambda e: self.base64Button.configure(
bg=ButtonStyle.BASE64_BUTTON["activebackground"]))
self.base64Button.bind("<Leave>", lambda e: self.base64Button.configure(
bg=ButtonStyle.BASE64_BUTTON["bg"]))
else:
self.classicButton = tk.Button(self, text="Classic",
command=lambda: self.master.switch_frame(EncryptMenu, process=self.process, dataFormat=self.dataFormat,
cipher=self.cipher, cipherMode="Classic")
if self.process == "Encrypt" else \
self.master.switch_frame(DecryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher=self.cipher, cipherMode="Classic"), **ButtonStyle.CLASSIC_BUTTON)
self.classicText = tk.Label(self, text=self.classic_text, wraplength=300, bg=Colours.WHITE,
fg=Colours.INFO, font=Fonts.INFO)
self.verticalSeparator = tk.ttk.Separator(self, orient="vertical")
self.asciiButton = tk.Button(self, text="ASCII",
command=lambda: self.master.switch_frame(EncryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher=self.cipher, cipherMode="ASCII")
if self.process == "Encrypt" else \
self.master.switch_frame(DecryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher=self.cipher, cipherMode="ASCII"), **ButtonStyle.ASCII_BUTTON)
self.ASCII_Text = tk.Label(self, text=self.ascii_text, bg=Colours.WHITE,
wraplength=310, fg=Colours.INFO, font=Fonts.INFO)
self.classicButton.grid(padx=20)
self.classicText.grid(row=1, padx=20, pady=10)
self.verticalSeparator.grid(column=1, row=0, rowspan=1, sticky="ns")
self.asciiButton.grid(column=2, row=0, padx=20)
self.ASCII_Text.grid(column=2, row=1, padx=20, pady=10)
if self.dataFormat == "Files":
self.base64Button = tk.Button(self, text="Base64",
command=lambda: self.master.switch_frame(EncryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher=self.cipher, cipherMode="Base64")
if self.process == "Encrypt" else \
self.master.switch_frame(DecryptMenu, process=self.process,
dataFormat=self.dataFormat, cipher=self.cipher, cipherMode="Base64"), **ButtonStyle.BASE64_BUTTON)
self.Base64_Text = tk.Label(self, text=self.base64_text, bg=Colours.WHITE,
wraplength=220, fg=Colours.INFO, font=Fonts.INFO)
self.verticalSeparator2 = tk.ttk.Separator(self, orient="vertical")
self.verticalSeparator2.grid(column=3, row=0, rowspan=1, sticky="ns")
self.base64Button.grid(column=4, row=0, padx=20)
self.Base64_Text.grid(column=4, row=1, padx=20, pady=10)
self.base64Button.bind("<Enter>", lambda e: self.base64Button.configure(
bg=ButtonStyle.BASE64_BUTTON["activebackground"]))
self.base64Button.bind("<Leave>", lambda e: self.base64Button.configure(
bg=ButtonStyle.BASE64_BUTTON["bg"]))
# Creates hover listeners for the buttons to change colour when hovered
self.classicButton.bind("<Enter>", lambda e: self.classicButton.configure(
bg=ButtonStyle.CLASSIC_BUTTON["activebackground"]))
self.classicButton.bind("<Leave>", lambda e: self.classicButton.configure(
bg=ButtonStyle.CLASSIC_BUTTON["bg"]))
self.asciiButton.bind("<Enter>", lambda e: self.asciiButton.configure(
bg=ButtonStyle.ASCII_BUTTON["activebackground"]))
self.asciiButton.bind("<Leave>", lambda e: self.asciiButton.configure(
bg=ButtonStyle.ASCII_BUTTON["bg"]))
class EncryptMenu(tk.Frame):
"""Creates the encryption page frame"""
def __init__(self, master, process, dataFormat, cipher, cipherMode):
tk.Frame.__init__(self, master)
self.process = process
self.dataFormat = dataFormat
self.cipher = cipher
self.cipherMode = cipherMode
self.configure(background=Colours.GREY_BACKGROUND, padx=10, pady=50)
# Initialises the icon used for this frame
self.icon = Image.open("Images/copyIcon.png")
self.icon2 = Image.open("Images/imageUpload.png")
# Makes the icon able to be used by widgets with these references
self.COPY_ICON = ImageTk.PhotoImage(self.icon)
self.IMAGE_UPLOAD = ImageTk.PhotoImage(self.icon2)
"""
Calls the necessary functions that create the widgets
for the corresponding section based on the data format
"""
if self.dataFormat == "Messages":
# Triple DES requires a separate section
if self.cipher == "Triple DES Cipher":
self.messageSectionForTripleDES()
else:
self.messageSection()
elif self.dataFormat == "Files":
if self.cipher == "Triple DES Cipher":
self.fileSectionForTripleDES()
else:
self.fileSection()
elif self.dataFormat == "Images":
if self.cipher == "Triple DES Cipher":
self.imageSectionForTripleDES()
else:
self.imageSection()
def messageSection(self):
def updateOutputBox():
"""
Gets the contents of the input and key boxes, then checks them for
validation, before retrieving the ciphertext from the
multicrypt module. Lastly, the ciphertext is placed in the output box.
"""
p = self.inputBox.get()
k = self.keyBox.get()
self.outputBox.delete("1.0", "end")
self.outputBox.configure(state="disabled", cursor="X_cursor")
self.error.grid(sticky="w", pady=(5, 0))
""" Input validation """
if p == "":
self.errorMessage.set("The plaintext field is empty.")
return None
if k == "":
self.errorMessage.set("The key field is empty.")
return None
if len(k) < 8:
self.errorMessage.set("The key must be at least 8 characters long.")
return None
# ONLY for Vigenere Cipher in CLASSIC mode
if self.cipher == "Vigenere Cipher" and self.cipherMode == "Classic" and not(k.isalpha()):
self.errorMessage.set("The key must not contain any ASCII characters.")
return None
self.error.grid_forget() # Removes the error message
self.errorMessage.set("")
cipherText, timeTaken = multicrypt.encrypt(plaintext=p, passKey=k, cipher=self.cipher,
dataformat=self.dataFormat, cipherMode=self.cipherMode)
self.outputBox.configure(state="normal", cursor="xterm")
self.outputBox.insert("1.0", cipherText)
def copyInputToClipboard():
i = self.inputBox.get()
i = i.split("\n")[0] # The new line character is ommited.
self.master.clipboard_clear()
self.master.clipboard_append(i)
def copyOutputToClipboard():
o = self.outputBox.get("1.0", "end")
o = o.split("\n")[0] # The new line character is ommited.
self.master.clipboard_clear()
self.master.clipboard_append(o)
self.errorMessage = tk.StringVar() # Text variable that stores the different error messages
self.master = self.winfo_toplevel() # Gets the top level window
"""
Creates a header:
The header frame is placed in the main application (master frame),
separate from the current frame.
"""
self.header = tk.Frame(self.master, bg=Colours.MAIN)
self.Logo = tk.Label(self.header, text="Padlock", bg=Colours.MAIN, fg=Colours.LOGO, font=Fonts.LOGO)
self.homeTag = tk.Label(self.header, text="Home", bg=Colours.MAIN, fg=Colours.TAGS_NOT_ACTIVE,
font=Fonts.TAGS, cursor="hand2")
self.sectionTag = tk.Label(self.header, text=self.process, bg=Colours.MAIN, fg=Colours.TAGS_NOT_ACTIVE,
font=Fonts.TAGS, cursor="hand2")
self.sectionTag2 = tk.Label(self.header, text=self.dataFormat, bg=Colours.MAIN, fg=Colours.TAGS_NOT_ACTIVE,
font=Fonts.TAGS, cursor="hand2")
self.sectionTag3 = tk.Label(self.header, text=self.cipherMode, bg=Colours.MAIN, fg=Colours.TAGS_NOT_ACTIVE,
font=Fonts.TAGS, cursor="hand2")
self.sectionTag4 = tk.Label(self.header, text=self.cipher, bg=Colours.WHITE, fg=Colours.FOREGROUND,
font=Fonts.TAGS)
self.header.grid(row=0, sticky="new")
self.Logo.grid(padx=20, pady=20)
self.homeTag.grid(column=1, row=0, padx=10, pady=(10, 0))
self.sectionTag.grid(column=2, row=0, pady=(10, 0), padx=10)
self.sectionTag2.grid(column=3, row=0, pady=(10, 0), padx=10)
# DES cipher and AES cipher have no modes so this won't display the mode tag
if self.cipher in ("DES Cipher", "AES Cipher", "RC4 Cipher"):
self.sectionTag4.grid(column=5, row=0, sticky="ns", ipadx=40, pady=(10, 0), padx=10)
else:
self.sectionTag3.grid(column=4, row=0, pady=(10, 0), padx=10)
self.sectionTag4.grid(column=5, row=0, sticky="ns", ipadx=40, pady=(10, 0), padx=10)
# Adds an event handler for the tag to act like a link when clicked
self.homeTag.bind("<Button-1>", lambda e: self.master.switch_frame(HomePage))
self.sectionTag.bind("<Button-1>", lambda e: self.master.switch_frame(FormatSelctionMenu, process=self.process))
self.sectionTag2.bind("<Button-1>", lambda e: self.master.switch_frame(CipherMenu, process=self.process,
dataFormat=self.dataFormat))
self.sectionTag3.bind("<Button-1>", lambda e: self.master.switch_frame(CipherModeMenu, process=self.process,
dataFormat=self.dataFormat, cipher=self.cipher))
"""Input frame section"""
self.inputFrame = tk.Frame(self, bg=Colours.WHITE)
self.subFrame = tk.Frame(self.inputFrame, bg=Colours.WHITE)
self.title = tk.Label(self.subFrame, text="Plaintext", bg=Colours.WHITE, fg=Colours.TITLE_FG, font=Fonts.TITLE)
self.copyButton = tk.Button(self.subFrame, text="Copy Plaintext", compound="left", image=self.COPY_ICON,
command=lambda: copyInputToClipboard(), **ButtonStyle.COPY_BUTTON)
self.horizontalSeparator = tk.ttk.Separator(self.inputFrame, orient="horizontal")
self.subFrame2 = tk.Frame(self.inputFrame, bg=Colours.WHITE)
self.inputBox = tk.Entry(self.subFrame2, width=24, font=Fonts.TEXT, relief="flat")
self.inputScrollbar = tk.Scrollbar(self.subFrame2, orient="horizontal", command=self.inputBox.xview)
self.inputBox['xscrollcommand'] = self.inputScrollbar.set
"""Control frame section"""
self.controlFrame = tk.Frame(self, bg=Colours.WHITE)
self.subFrame3 = tk.Frame(self.controlFrame, bg=Colours.WHITE)
self.cipherLabel = tk.Label(self.subFrame3, text=self.cipher, bg=Colours.WHITE, fg=Colours.CIPHER_FG,
font=Fonts.TITLE)
self.horizontalSeparator2 = tk.ttk.Separator(self.controlFrame, orient="horizontal")
self.subFrame4 = tk.Frame(self.controlFrame, bg=Colours.WHITE)
self.subtext = tk.Label(self.subFrame4, text="KEY", bg=Colours.WHITE, fg=Colours.SMALL_TITLE, font=Fonts.TITLE2)
self.keyBox = tk.Entry(self.subFrame4, width=22, relief="flat", font=Fonts.KEY_TEXT, highlightthickness="1",
highlightcolor=Colours.ORANGE, highlightbackground=Colours.GREY_FOREGROUND)
self.horizontalSeparator3 = tk.ttk.Separator(self.controlFrame, orient="horizontal")
self.subFrame5 = tk.Frame(self.controlFrame, bg=Colours.WHITE)
self.encryptButton = tk.Button(self.subFrame5, text="Encrypt", command=lambda: updateOutputBox(),
**ButtonStyle.ENCRYPT2_BUTTON)
self.error = tk.Label(self.subFrame5, textvariable=self.errorMessage, wraplength=200, justify="left",
bg=Colours.WHITE, fg=Colours.ERROR, font=Fonts.ERROR)
"""Output frame section"""
self.outputFrame = tk.Frame(self, bg=Colours.WHITE)
self.subFrame6 = tk.Frame(self.outputFrame, bg=Colours.WHITE)
self.title2 = tk.Label(self.subFrame6, text="Ciphertext", bg=Colours.WHITE, fg=Colours.TITLE2_FG, font=Fonts.TITLE)
self.copyButton2 = tk.Button(self.subFrame6, text="Copy Ciphertext", compound="left", image=self.COPY_ICON,
command=lambda: copyOutputToClipboard(), **ButtonStyle.COPY_BUTTON)
self.horizontalSeparator4 = tk.ttk.Separator(self.outputFrame, orient="horizontal")
self.subFrame7 = tk.Frame(self.outputFrame, bg=Colours.WHITE)
self.outputBox = tk.Text(self.subFrame7, width=25, height=5, bd=0, wrap="word", bg=Colours.WHITE,
fg=Colours.GREY_FOREGROUND, font=Fonts.TEXT, state="disabled", cursor="X_cursor")
self.outputScrollbar = tk.Scrollbar(self.subFrame7, command=self.outputBox.yview)
self.outputBox['yscrollcommand'] = self.outputScrollbar.set
"""Widget placment"""
self.inputFrame.grid(padx=50, sticky="n")
self.subFrame.grid(sticky="w")
self.title.grid(padx=16, pady=16)
self.copyButton.grid(column=1, row=0, padx=5)
self.horizontalSeparator.grid(sticky="we")
self.subFrame2.grid(sticky="w")
self.inputBox.grid(padx=16, pady=10, ipady=10)
self.inputScrollbar.grid(row=1, column=0, sticky='we', padx=15, pady=(0, 70))
self.controlFrame.grid(column=1, row=0, padx=50, sticky="n")
self.subFrame3.grid(sticky="w")
self.cipherLabel.grid(padx=16, pady=16)
self.horizontalSeparator2.grid(sticky="we")
self.subFrame4.grid()
self.subtext.grid(sticky="w", pady=(8, 0))
self.keyBox.grid(padx=10, pady=10, ipady=5)
self.horizontalSeparator3.grid(sticky="we")
self.subFrame5.grid(sticky="w", padx=10, pady=10)
self.encryptButton.grid()
self.outputFrame.grid(column=2, row=0, padx=50, sticky="n")
self.subFrame6.grid(sticky="w")
self.title2.grid(padx=16, pady=16)
self.copyButton2.grid(column=1, row=0, padx=5)
self.horizontalSeparator4.grid(sticky="we")
self.subFrame7.grid(sticky="w")
self.outputBox.grid(padx=16, pady=25)
self.outputScrollbar.grid(row=0, column=1, sticky='nsew')
""" Hover effects """
self.encryptButton.bind("<Enter>", lambda e: self.encryptButton.configure(
bg=ButtonStyle.ENCRYPT2_BUTTON["activebackground"]))
self.encryptButton.bind("<Leave>", lambda e: self.encryptButton.configure(
bg=ButtonStyle.ENCRYPT2_BUTTON["bg"]))
self.copyButton.bind("<Enter>", lambda e: self.copyButton.configure(
bg=ButtonStyle.COPY_BUTTON["activebackground"]))
self.copyButton.bind("<Leave>", lambda e: self.copyButton.configure(
bg=ButtonStyle.COPY_BUTTON["bg"]))
self.copyButton2.bind("<Enter>", lambda e: self.copyButton2.configure(
bg=ButtonStyle.COPY_BUTTON["activebackground"]))
self.copyButton2.bind("<Leave>", lambda e: self.copyButton2.configure(
bg=ButtonStyle.COPY_BUTTON["bg"]))
def messageSectionForTripleDES(self):
def updateOutputBox():
"""
Gets the contents of the input and key boxes, then checks them for
validation, before retrieving the ciphertext from the
multicrypt module. The ciphertext is then placed in the output box.
"""
p = self.inputBox.get()
k = self.keyBox.get()
k2 = self.keyBox2.get()
k3 = self.keyBox3.get()
self.outputBox.delete("1.0", "end")
self.outputBox.configure(state="disabled", cursor="X_cursor")
self.error.grid(sticky="w", pady=(5, 0))
""" Input validation """
if p == "":
self.errorMessage.set("The plaintext field is empty.")
return None
if k == "":
self.errorMessage.set("The key field is empty.")
return None
if len(k) < 8:
self.errorMessage.set("The first key must be at least 8 characters long.")
return None
if k2 == "":
self.errorMessage.set("The second key field is empty.")
return None
if len(k2) < 8:
self.errorMessage.set("The second key must be at least 8 characters long.")
return None
if k3 == "":
self.errorMessage.set("The third key field is empty.")
return None
if len(k3) < 8:
self.errorMessage.set("The third key must be at least 8 characters long.")
return None
self.error.grid_forget() # Removes the error message
self.errorMessage.set("")
cipherText, timeTaken = multicrypt.encrypt(plaintext=p, passKey=(k, k2, k3),
cipher=self.cipher, dataformat=self.dataFormat)
self.outputBox.configure(state="normal", cursor="xterm")
self.outputBox.insert("1.0", cipherText)
def copyInputToClipboard():
i = self.inputBox.get()
i = i.split("\n")[0] # The new line character is ommited.
self.master.clipboard_clear()
self.master.clipboard_append(i)
def copyOutputToClipboard():
o = self.outputBox.get("1.0", "end")
o = o.split("\n")[0] # The new line character is ommited.
self.master.clipboard_clear()
self.master.clipboard_append(o)
self.errorMessage = tk.StringVar() # Text variable that stores the different error messages
self.master = self.winfo_toplevel() # Gets the top level window
"""
Creates a header:
The header frame is placed in the main application (master frame),
separate from the current frame.
"""
self.header = tk.Frame(self.master, bg=Colours.MAIN)
self.Logo = tk.Label(self.header, text="Padlock", bg=Colours.MAIN, fg=Colours.LOGO, font=Fonts.LOGO)
self.homeTag = tk.Label(self.header, text="Home", bg=Colours.MAIN, fg=Colours.TAGS_NOT_ACTIVE,
font=Fonts.TAGS, cursor="hand2")
self.sectionTag = tk.Label(self.header, text=self.process, bg=Colours.MAIN, fg=Colours.TAGS_NOT_ACTIVE,
font=Fonts.TAGS, cursor="hand2")
self.sectionTag2 = tk.Label(self.header, text=self.dataFormat, bg=Colours.MAIN, fg=Colours.TAGS_NOT_ACTIVE,
font=Fonts.TAGS, cursor="hand2")
self.sectionTag3 = tk.Label(self.header, text=self.cipher, bg=Colours.WHITE, fg=Colours.FOREGROUND,
font=Fonts.TAGS)
self.header.grid(row=0, sticky="new")
self.Logo.grid(padx=20, pady=20)
self.homeTag.grid(column=1, row=0, padx=10, pady=(10, 0))
self.sectionTag.grid(column=2, row=0, pady=(10, 0), padx=10)
self.sectionTag2.grid(column=3, row=0, pady=(10, 0), padx=10)
self.sectionTag3.grid(column=4, row=0, sticky="ns", ipadx=40, pady=(10, 0), padx=10)
# Adds an event handler for the tag to act like a link when clicked
self.homeTag.bind("<Button-1>", lambda e: self.master.switch_frame(HomePage))
self.sectionTag.bind("<Button-1>", lambda e: self.master.switch_frame(FormatSelctionMenu, process=self.process))
self.sectionTag2.bind("<Button-1>", lambda e: self.master.switch_frame(CipherMenu, process=self.process,
dataFormat=self.dataFormat))
"""Input frame section"""
self.inputFrame = tk.Frame(self, bg=Colours.WHITE)
self.subFrame = tk.Frame(self.inputFrame, bg=Colours.WHITE)
self.title = tk.Label(self.subFrame, text="Plaintext", bg=Colours.WHITE, fg=Colours.TITLE_FG, font=Fonts.TITLE)
self.copyButton = tk.Button(self.subFrame, text="Copy Plaintext", compound="left", image=self.COPY_ICON,
command=lambda: copyInputToClipboard(), **ButtonStyle.COPY_BUTTON)
self.horizontalSeparator = tk.ttk.Separator(self.inputFrame, orient="horizontal")
self.subFrame2 = tk.Frame(self.inputFrame, bg=Colours.WHITE)
self.inputBox = tk.Entry(self.subFrame2, width=24, font=Fonts.TEXT, relief="flat")
self.inputScrollbar = tk.Scrollbar(self.subFrame2, orient="horizontal", command=self.inputBox.xview)
self.inputBox['xscrollcommand'] = self.inputScrollbar.set
"""Control frame section"""
self.controlFrame = tk.Frame(self, bg=Colours.WHITE)
self.subFrame3 = tk.Frame(self.controlFrame, bg=Colours.WHITE)
self.cipherLabel = tk.Label(self.subFrame3, text=self.cipher, bg=Colours.WHITE, fg=Colours.CIPHER_FG,
font=Fonts.TITLE)
# Key section 1
self.horizontalSeparator2 = tk.ttk.Separator(self.controlFrame, orient="horizontal")
self.subFrame4 = tk.Frame(self.controlFrame, bg=Colours.WHITE)
self.subtext = tk.Label(self.subFrame4, text="KEY", bg=Colours.WHITE, fg=Colours.SMALL_TITLE,
font=Fonts.TITLE2)
self.keyBox = tk.Entry(self.subFrame4, width=22, relief="flat", font=Fonts.KEY_TEXT, highlightthickness="1",
highlightcolor=Colours.ORANGE, highlightbackground=Colours.GREY_FOREGROUND)
# Key section 2
self.horizontalSeparator3 = tk.ttk.Separator(self.controlFrame, orient="horizontal")
self.subFrame5 = tk.Frame(self.controlFrame, bg=Colours.WHITE)
self.subtext2 = tk.Label(self.subFrame5, text="SECOND KEY", bg=Colours.WHITE, fg=Colours.SMALL_TITLE,
font=Fonts.TITLE2)
self.keyBox2 = tk.Entry(self.subFrame5, width=22, relief="flat", font=Fonts.KEY_TEXT, highlightthickness="1",
highlightcolor=Colours.ORANGE, highlightbackground=Colours.GREY_FOREGROUND)
# Key section 3
self.horizontalSeparator4 = tk.ttk.Separator(self.controlFrame, orient="horizontal")
self.subFrame6 = tk.Frame(self.controlFrame, bg=Colours.WHITE)
self.subtext3 = tk.Label(self.subFrame6, text="THIRD KEY", bg=Colours.WHITE, fg=Colours.SMALL_TITLE,
font=Fonts.TITLE2)
self.keyBox3 = tk.Entry(self.subFrame6, width=22, relief="flat", font=Fonts.KEY_TEXT, highlightthickness="1",
highlightcolor=Colours.ORANGE, highlightbackground=Colours.GREY_FOREGROUND)
self.horizontalSeparator5 = tk.ttk.Separator(self.controlFrame, orient="horizontal")
self.subFrame7 = tk.Frame(self.controlFrame, bg=Colours.WHITE)
self.encryptButton = tk.Button(self.subFrame7, text="Encrypt", command=lambda: updateOutputBox(),
**ButtonStyle.ENCRYPT2_BUTTON)
self.error = tk.Label(self.subFrame7, textvariable=self.errorMessage, wraplength=200, justify="left",
bg=Colours.WHITE, fg=Colours.ERROR, font=Fonts.ERROR)
"""Output frame section"""
self.outputFrame = tk.Frame(self, bg=Colours.WHITE)
self.subFrame8 = tk.Frame(self.outputFrame, bg=Colours.WHITE)
self.title2 = tk.Label(self.subFrame8, text="Ciphertext", bg=Colours.WHITE, fg=Colours.TITLE2_FG, font=Fonts.TITLE)
self.copyButton2 = tk.Button(self.subFrame8, text="Copy Ciphertext", compound="left", image=self.COPY_ICON,
command=lambda: copyOutputToClipboard(), **ButtonStyle.COPY_BUTTON)
self.horizontalSeparator6 = tk.ttk.Separator(self.outputFrame, orient="horizontal")
self.subFrame9 = tk.Frame(self.outputFrame, bg=Colours.WHITE)
self.outputBox = tk.Text(self.subFrame9, width=25, height=10, bd=0, wrap="word", bg=Colours.WHITE,
fg=Colours.GREY_FOREGROUND, font=Fonts.TEXT, state="disabled", cursor="X_cursor")
self.outputScrollbar = tk.Scrollbar(self.subFrame9, command=self.outputBox.yview)
self.outputBox['yscrollcommand'] = self.outputScrollbar.set
"""Widget placment"""
self.inputFrame.grid(padx=50, sticky="n")
self.subFrame.grid(sticky="w")
self.title.grid(padx=16, pady=16)
self.copyButton.grid(column=1, row=0, padx=5)
self.horizontalSeparator.grid(sticky="we")
self.subFrame2.grid(sticky="w")
self.inputBox.grid(padx=16, pady=10, ipady=10)
self.inputScrollbar.grid(row=1, column=0, sticky='we', padx=15, pady=(0, 155))
self.controlFrame.grid(column=1, row=0, padx=50, sticky="n")
self.subFrame3.grid(sticky="w")
self.cipherLabel.grid(padx=16, pady=16)
self.horizontalSeparator2.grid(sticky="we")
self.subFrame4.grid()
self.subtext.grid(sticky="w", pady=(8, 0))
self.keyBox.grid(padx=10, pady=8, ipady=3)
self.horizontalSeparator3.grid(sticky="we")
self.subFrame5.grid()
self.subtext2.grid(sticky="w", pady=(8, 0))
self.keyBox2.grid(padx=10, pady=8, ipady=3)
self.horizontalSeparator4.grid(sticky="we")