-
Notifications
You must be signed in to change notification settings - Fork 0
/
mtt.py
976 lines (789 loc) · 63 KB
/
mtt.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
#!/usr/bin/python3
from itertools import count
from urllib.parse import quote, unquote
import os, shutil, base64, codecs, html, binascii, sqlite3, tempfile, webbrowser, pyperclip, time, requests
from datetime import datetime
try:
from bs4 import BeautifulSoup
except(ModuleNotFoundError):
print("[Error] Module not found: bs4\n[Info] Try installing it with: pip3 install bs4")
exit()
try:
import PySimpleGUI as sg
except(ModuleNotFoundError):
print("[Error] Module not found: pysimplegui\n[Info] Try installing it with: pip3 install pysimplegui")
exit()
# Globals
mttGithubUpdateURL = "https://raw.githubusercontent.com/shafdo/Mini-Text-Toolkit/master/mtt.py"
currentDir = os.path.dirname(__file__)
sgThemeGlobal = ""
platform = "windows" if(os.name) else "linux"
version = "1.0"
# Icons
aboutImgData = b'iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFP0lEQVR4nO2Y7U9TVxzHGXvp9hcse7f1uaVPSQtuMxmSZWuoXUYMwqI4tbzwxabR1czE4KagYWlLl2I7kLbJeNgLN6ZbdFBELSAlS5SRLBKzFyzbMhITH0qviobffqeu19729nIv9CHc3W/yDYHb8zu/7+dezj09FRWSJEmSJEmSJEmSiiOz2bzFZDL1G43GOfTvPD1HxhgMhrfK3f+6hEFOYxBYj0mNcudYk7D5vesNn+E95c4jVC9g0wssd/MH/HkE7crjI/iZYRYAC6RmuUPxFv7vvsYSPsJ3PH4+nD2e1CxmzwUVNmxhuYsNAsY3sACoLmbPBRXebWt2AHwb2PmOx7D1LONritlzQSUKAAAVlY8m7bbkhL19KeZwC/Gt720DoRO1kOkb39qG+Y6/MfTucPb4376zDQntI9X7VbtNcPjERP2HVLw58fCXfSAGU9PNicSUvZlXeGpqWxM189FKuZsuOATMlLj23o7VAVxvus8YPNOC3rVB3ZL9JNzjDP94qn77s9C7gbr2DiRHTbA0atjQTkbNqSwkUwpCrH47x+P/wRihlrxcXfbGCw4CM5Fs1FRDND8AXPiSV98ue7NFg3ClNrUgsoZ/MG1XUTM7y95ksU0yJsZtmhwAySlHX3JyW9kbLPpTgBmpSUdvDoCH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ecypSp7SMP+cAtBh3LmTPewD/B5i6wX2BCv10AAAAAElFTkSuQmCC'
copy2clipboardImgData = b'iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAAAjBJREFUSEvtl01oE2EQht/Z3USNVBFEza34V+hBhPRHsR704G5uQqHNlmovBcFDPQTEqyB4KgqCICKI0SQUA4KHTVKVgAdJukHwIN4FBfEYIT+730gCgU1M2l22MZfs8WO+ed55v2GGJQzpoyFx0QGeeHZh7GBo7A2BgpBcSBKYBHCjqBuvXUR3hHSAIwk1rCi0XtSzS24SzaS0CggWMa16hXeCM2pYqXsAp6PfBEOXCY+YxeOSnku6EdyM8QnWTCGwLkt0CsAdG5g3Y4bhBu4LPLWhTZCNVQD7iIgJ1ttibDM/cLATcObFlf17A3QLEgVa50QfSwvGh34ifFXsTBrJqGG5DgOQNhhiTgJdFHbj8tbyexMAdwvYVXC7MWeT0ThLmANwVsC+acby/7z7QMDTKW2NiI9YsF8pCGSEZcfN5XzWWflAwJHn0RPKHi6CUAPoEDNXba6eLi8VfrctHwi4mfx8Qj1pBTHe6jOBWuhY7VPhUsEaONjZTNNp7X6tLh58uZ7/9V/BsyktaQU5Xp7P/RyBWw40h4CXJdE9QPrdHVntey3untUJNSwr9LCkZxfdrDZnzLmUNi6I7pZixkr33Z3f+EkkJB84/BRCOtrcr84EgsRxYvpOoEYvUUwiwBLf21rMvfMM3q7KXqrdurJjxSOw04GZdPRlg63bn/XNH24tbse1rLY4Xr7WZ1Zvl3AqrcUkxhoR/ngFM4MqcvXq14VCpeeS8JrQT/zQ/p3+AviYoS4NqkdZAAAAAElFTkSuQmCC'
class historyLogger():
def createDB(self):
conn = sqlite3.connect('.mtt-history.db')
if(platform == "windows"): os.system("attrib +h .mtt-history.db")
cursor = conn.cursor()
try:
cursor.execute('CREATE TABLE history ( id INTEGER PRIMARY KEY AUTOINCREMENT, today DATE, time INTEGER, convertFrom TEXT, convertValue TEXT )')
except(sqlite3.OperationalError):
pass
return conn
def resetDB(self, conn):
cursor = conn.cursor()
try:
cursor.execute("DELETE FROM history;")
conn.commit()
return True
except(sqlite3.OperationalError):
return False
def log(self, conn, convertFrom, convertValue):
cursor = conn.cursor()
today = datetime.today().strftime("%b-%d-%Y")
time = datetime.today().strftime("%H:%M")
query = "INSERT INTO history(today, time, convertfrom, convertvalue) VALUES (?,?,?,?)"
cursor.execute(query, (today, time, convertFrom, convertValue))
conn.commit()
def display(self, conn):
''' History Output Structure
/\/\/\/\/\/\/ DATE /\/\/\/\/\/\/
ConvertFromType Value
Ex: Binary 1001110
'''
cursor = conn.cursor()
content = {}
for row in cursor.execute("SELECT DISTINCT today FROM history ORDER BY today DESC;"):
content[str(row[0])] = []
for key, value in content.items():
query = "SELECT id, time, convertFrom, convertValue FROM history WHERE today='{}'".format(key)
for row in cursor.execute(query):
content[key].append(row)
return content
def createTempFolder(self):
return tempfile.mkdtemp()
def removeTempFolder(self, tempFolderPath):
print("[Info] Removing mtt temp folder.")
try: shutil.rmtree(tempFolderPath)
except: print("[Error] Removing temp folder ended up with an error.")
print("[Info] Removing temp folder successfull.")
def webTempFile(self, tempFolderPath, html):
tempFile = os.path.join(tempFolderPath, "{}.html".format(next(tempfile._get_candidate_names())))
# Write default HTML stuff
defaultDocumentHTML = r'<!DOCTYPE html><html lang="en"> <head> <meta charset="UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta name="viewport" content="width=device-width,initial-scale=1"/> <title>MTT History</title> <style>::-webkit-scrollbar{width:10px;height:8px;}::-webkit-scrollbar-track{background:#585858}::-webkit-scrollbar-thumb{background:#53e623;border-radius:50px;}::-webkit-scrollbar-thumb:hover{background:#41b11d}body{background-color:#222}.row{margin-bottom:50px}.para-wrapper{margin-left:25px;padding-left:15px;border-left:4px solid #ff007b}.divider{border:none;border-bottom:4px solid #ff007b}.green{color:#53e623}h2{color:#37b2ca}.text-white{color:#c1c1c1}p{overflow-x: auto;font-size:18px;color:#c1c1c1;font-family:Ubuntu,sans-serif;line-height:30px}.convert-from-value{text-transform: capitalize;}.pl-4{padding-left:10px}#content{margin:25px}#header-wrapper>h1{padding-left: 20px;color:#ffe000;font-family:Ubuntu,sans-serif}#export2csv{background-color:#4aca37;border-radius:50px;height:40px;color:#fff;font-weight:700;padding:0 20px;margin:20px;font-size:16px;border:3px solid #4aca37;cursor:pointer;transition:.5s;}#export2csv:hover{border:3px solid #fff;background-color:transparent;}</style> </head> <body> <div id="header-wrapper" style="display: flex; justify-content: space-between;"> <h1>MTT Histroy</h1> <button id="export2csv">Export to CSV</button> </div><ul class="text-white"> <li><p class="pl-4">Thank you for trying out MTT :).</p></li></ul> <div id="content"></div><script>document.querySelector("#export2csv").addEventListener("click",e=>{e.stopPropagation();const t=[["Time","Convert From","Value"]];document.querySelectorAll("p").forEach(e=>{let a=[];e.childNodes.forEach(e=>{switch(e.className){case"time-value":case"convert-from-value":case"convert-value":a.push(e.innerText)}}),0!=a.length&&t.push(a)});let a=t.map(function(e){return e.join()}).join("\n");a="data:text/csv;charset=utf-8,"+escape(a);var c=document.createElement("a");c.href=a,c.download="mttHistory.csv",c.click()});</script></body></html>'
soup = BeautifulSoup(defaultDocumentHTML, "html.parser")
soup.find("div", {"id": "content"}).append(BeautifulSoup(html, 'html.parser'))
f = open(tempFile, "w")
f.write(soup.prettify())
f.close()
print("[Info] Opening mtt history in browser.")
webbrowser.open(tempFile)
conn = historyLogger().createDB()
tempFolderPath = historyLogger().createTempFolder()
print("\n"+r"/\/\/\/\/ Starting Logger /\/\/\/\/")
print('[Info] Temp folder created at path: {}'.format(tempFolderPath))
class Convertor():
def paddingFixer(self, convertValue, skipper):
allXChars = [i for i in convertValue]
bitsSplitContainer = []
while 1:
if(len(allXChars) == 0): break
elif(len(allXChars) >= skipper):
bitsSplitContainer.append("".join(allXChars[:skipper]))
del allXChars[:skipper]
else: allXChars.insert(0, "0")
return "".join(bitsSplitContainer)
# Nicely separate the results coming from paddingFixer => [result[i:i+skipper] for i in range(0, len(result), skipper)]
def fromAscii(self, convertMethod, convertValue):
if(convertMethod == "ascii2bin"):
allChars = [i for i in convertValue]
binariesContainer = []
for char in allChars:
binaryVal = bin(ord(char)).replace("0b", "0")
if(len(binaryVal) == 8): binariesContainer.append(binaryVal)
else:
binariesContainer.append("0" * (8 - len(binaryVal)) + binaryVal)
return " ".join(binariesContainer)
# Old Method (Works but prone to some error).
# return "0" +' 0'.join(format(ord(x), 'b') for x in convertValue)
if(convertMethod == "ascii2hex"):
return " ".join("{:02x}".format(ord(x)) for x in convertValue)
if(convertMethod == "ascii2base64"):
return base64.b64encode(convertValue.encode()).decode("utf-8")
if(convertMethod == "ascii2dec"):
return " ".join([str(ord(x)) for x in convertValue])
if(convertMethod == "ascii2rot13"):
return codecs.encode(convertValue, "rot_13")
if(convertMethod == "ascii2rot47"):
# Found this method of representing ROT47 from https://rot47.net/
x = []
for i in range(len(convertValue)):
j = ord(convertValue[i])
if j >= 33 and j <= 126:
x.append(chr(33 + ((j + 14) % 94)))
else:
x.append(convertValue[i])
return ''.join(x)
if(convertMethod == "ascii2urlencode"):
return quote(convertValue, 'utf-8')
if(convertMethod == "ascii2htmlentities"):
return html.escape(convertValue)
def fromBin(self, convertMethod, convertValue):
if(convertMethod == "bin2ascii"):
try:
return binascii.unhexlify('%x' % int(str(convertValue), 2)).decode("ascii", "ignore")
except(UnicodeDecodeError):
return "�"
except ValueError:
return ""
if(convertMethod == "bin2hex"):
if(len(convertValue) % 8 == 0):
hexValWithout0x = hex(int(convertValue, 2))[2:]
hexValSpaceInBetween = " ".join([hexValWithout0x[i:i+2] for i in range(0, len(hexValWithout0x), 2)])
return hexValSpaceInBetween
else:
# Fix Padding
return self.fromBin("bin2hex", self.paddingFixer(convertValue, 8))
if(convertMethod == "bin2base64"):
getAscii = self.fromBin("bin2ascii", convertValue)
return base64.b64encode(getAscii.encode()).decode("utf-8")
if(convertMethod == "bin2decimal"):
decimalNumContainer = []
if(len(convertValue) % 8 == 0):
valuesSplitBy8 = [convertValue[i:i+8] for i in range(0, len(convertValue), 8)]
for val in valuesSplitBy8: decimalNumContainer.append(int(val, 2))
temp = [str(val) for val in decimalNumContainer]
return " ".join(temp)
else:
# Fix Padding
return self.fromBin("bin2decimal", "".join(self.paddingFixer(convertValue, 8)))
if(convertMethod == "bin2rot13"):
asciiVal = self.fromBin("bin2ascii", convertValue)
rot13Val = self.fromAscii("ascii2rot13", asciiVal)
return rot13Val
if(convertMethod == "bin2rot47"):
asciiVal = self.fromBin("bin2ascii", convertValue)
rot47Val = self.fromAscii("ascii2rot47", asciiVal)
return rot47Val
if(convertMethod == "bin2urlencode"):
asciiVal = self.fromBin("bin2ascii", convertValue)
urlEncoded = self.fromAscii("ascii2urlencode", asciiVal)
return urlEncoded
if(convertMethod == "bin2htmlentities"):
asciiVal = self.fromBin("bin2ascii", convertValue)
htmlEncoded = self.fromAscii("ascii2htmlentities", asciiVal)
return htmlEncoded
def fromHex(self, convertMethod, convertValue):
if(convertMethod == "hex2ascii"):
convertValue = self.paddingFixer(convertValue, 2)
return "".join(chr(int(val, 16)) for val in [convertValue[i:i+2] for i in range(0, len(convertValue), 2)])
if(convertMethod == "hex2bin"):
binaryString = bin(int(convertValue, 16))[2:].zfill(8)
return " ".join([binaryString[i:i+8] for i in range(0, len(binaryString), 8)])
if(convertMethod == "hex2base64"):
asciiString = self.fromHex("hex2ascii", convertValue)
return base64.b64encode(asciiString.encode()).decode("ASCII")
if(convertMethod == "hex2decimal"):
if(len(convertValue) % 2 == 0):
hexPairContainer = []
for hexPair in [convertValue[i:i+2] for i in range(0, len(convertValue), 2)]: hexPairContainer.append(str(int(hexPair, 16)))
return " ".join(hexPairContainer)
else:
# Fix Padding
return self.fromHex("hex2decimal", self.paddingFixer(convertValue, 2))
if(convertMethod == "hex2rot13"):
asciiVal = self.fromHex("hex2ascii", convertValue)
rot13Val = self.fromAscii("ascii2rot13", asciiVal)
return rot13Val
if(convertMethod == "hex2rot47"):
asciiVal = self.fromHex("hex2ascii", convertValue)
rot47Val = self.fromAscii("ascii2rot47", asciiVal)
return rot47Val
if(convertMethod == "hex2urlencode"):
asciiVal = self.fromHex("hex2ascii", convertValue)
urlEncoded = self.fromAscii("ascii2urlencode", asciiVal)
return urlEncoded
if(convertMethod == "hex2htmlentities"):
asciiVal = self.fromHex("hex2ascii", convertValue)
htmlEncoded = self.fromAscii("ascii2htmlentities", asciiVal)
return htmlEncoded
def fromBase64(self, convertMethod, convertValue):
if(convertMethod == "base642ascii"):
try:
return "".join([chr(i) for i in base64.standard_b64decode(convertValue)])
# Previous solution: Strips up unicode characters too
# return base64.b64decode(convertValue).decode("ascii", "ignore")
except(UnicodeDecodeError):
return "�"
except ValueError:
return ""
if(convertMethod == "base642bin"):
# To decode base64 format you need to pass a bytes object to the base64.decodebytes(). Reference: https://stackoverflow.com/a/43208125
base64Decoded = base64.decodebytes(convertValue.encode())
return " ".join(["{:08b}".format(x) for x in base64Decoded])
if(convertMethod == "base642hex"):
hexVal = base64.b64decode(convertValue.encode()).hex()
return " ".join([hexVal[i:i+2] for i in range(0, len(hexVal), 2)])
if(convertMethod == "base642decimal"):
# You need to convert each byte from the decoded string to its decimal value. Reference: https://stackoverflow.com/a/38878737
return ' '.join([str(i) for i in base64.standard_b64decode(convertValue)])
if(convertMethod == "base642rot13"):
asciiVal = self.fromBase64("base642ascii", convertValue)
rot13Val = self.fromAscii("ascii2rot13", asciiVal)
return rot13Val
if(convertMethod == "base642rot47"):
asciiVal = self.fromBase64("base642ascii", convertValue)
rot47Val = self.fromAscii("ascii2rot47", asciiVal)
return rot47Val
if(convertMethod == "base642urlencoded"):
asciiVal = self.fromBase64("base642ascii", convertValue)
urlFriendlyVal = self.fromAscii("ascii2urlencode", asciiVal)
return urlFriendlyVal
if(convertMethod == "base642htmlentities"):
asciiVal = self.fromBase64("base642ascii", convertValue)
htmlEncoded = self.fromAscii("ascii2htmlentities", asciiVal)
return htmlEncoded
def fromdec(self, convertMethod, convertValue):
if(convertMethod == "decimal2ascii"):
if(" " in convertValue):
valContainer = convertValue.split(" ")
return "".join(chr(int(val)) for val in valContainer)
else:
convertValue = self.paddingFixer(convertValue, 2)
return "".join([chr(int(num)) for num in [convertValue[i:i+2] for i in range(0, len(convertValue), 2)]])
if(convertMethod == "decimal2bin"):
if(" " in convertValue):
valContainer = convertValue.split(" ")
return " ".join(format(int(val), "08b") for val in valContainer)
else:
return bin(int(convertValue))[2:]
if(convertMethod == "decimal2hex"):
if(" " in convertValue):
container = convertValue.split(" ")
return " ".join(hex(int(val))[2:] for val in container)
else:
return hex(int(convertValue))[2:]
if(convertMethod == "decimal2base64"):
asciiVal = self.fromdec("decimal2ascii", convertValue)
return base64.b64encode(asciiVal.encode()).decode("utf-8", "ignore")
if(convertMethod == "decimal2rot13"):
asciiVal = self.fromdec("decimal2ascii", convertValue)
return self.fromAscii("ascii2rot13", asciiVal)
if(convertMethod == "decimal2rot47"):
asciiVal = self.fromdec("decimal2ascii", convertValue)
return self.fromAscii("ascii2rot47", asciiVal)
if(convertMethod == "decimal2urlencoded"):
asciiVal = self.fromdec("decimal2ascii", convertValue)
return self.fromAscii("ascii2urlencode", asciiVal)
if(convertMethod == "decimal2htmlentities"):
asciiVal = self.fromdec("decimal2ascii", convertValue)
return self.fromAscii("ascii2htmlentities", asciiVal)
def fromrot13(self, convertMethod, convertValue):
if(convertMethod == "rot132ascii"):return codecs.decode(convertValue, "rot_13")
if(convertMethod == "rot132bin"):return self.fromAscii("ascii2bin", convertValue)
if(convertMethod == "rot132hex"):return self.fromAscii("ascii2hex", convertValue)
if(convertMethod == "rot132base64"):return self.fromAscii("ascii2base64", convertValue)
if(convertMethod == "rot132decimal"):return self.fromAscii("ascii2dec", convertValue)
if(convertMethod == "rot132rot47"):return self.fromAscii("ascii2rot47", convertValue)
if(convertMethod == "rot132urlencoded"):return self.fromAscii("ascii2urlencode", convertValue)
if(convertMethod == "rot132htmlentities"):return self.fromAscii("ascii2htmlentities", convertValue)
def fromrot47(self, convertMethod, convertValue):
if(convertMethod == "rot472ascii"): return self.fromAscii("ascii2rot47", convertValue)
if(convertMethod == "rot472bin"): return self.fromAscii("ascii2bin", convertValue)
if(convertMethod == "rot472hex"): return self.fromAscii("ascii2hex", convertValue)
if(convertMethod == "rot472base64"): return self.fromAscii("ascii2base64", convertValue)
if(convertMethod == "rot472decimal"): return self.fromAscii("ascii2dec", convertValue)
if(convertMethod == "rot472rot13"): return self.fromAscii("ascii2rot13", convertValue)
if(convertMethod == "rot472urlencoded"): return self.fromAscii("ascii2urlencode", convertValue)
if(convertMethod == "rot472htmlentities"): return self.fromAscii("ascii2htmlentities", convertValue)
def fromurlencoded(self, convertMethod, convertValue):
if(convertMethod == "urlencoded2ascii"): return unquote(convertValue, 'utf-8')
if(convertMethod == "urlencoded2bin"):
urldecoded = self.fromurlencoded("urlencoded2ascii", convertValue)
return self.fromAscii("ascii2bin", urldecoded)
if(convertMethod == "urlencoded2hex"):
urldecoded = self.fromurlencoded("urlencoded2ascii", convertValue)
return self.fromAscii("ascii2hex", urldecoded)
if(convertMethod == "urlencoded2base64"):
urldecoded = self.fromurlencoded("urlencoded2ascii", convertValue)
return self.fromAscii("ascii2base64", urldecoded)
if(convertMethod == "urlencoded2decimal"):
urldecoded = self.fromurlencoded("urlencoded2ascii", convertValue)
return self.fromAscii("ascii2dec", urldecoded)
if(convertMethod == "urlencoded2rot13"):
urldecoded = self.fromurlencoded("urlencoded2ascii", convertValue)
return self.fromAscii("ascii2rot13", urldecoded)
if(convertMethod == "urlencoded2rot47"):
urldecoded = self.fromurlencoded("urlencoded2ascii", convertValue)
return self.fromAscii("ascii2rot47", urldecoded)
if(convertMethod == "urlencoded2htmlentities"):
urldecoded = self.fromurlencoded("urlencoded2ascii", convertValue)
return self.fromAscii("ascii2htmlentities", urldecoded)
def fromhtmlentities(self, convertMethod, convertValue):
if(convertMethod == "htmlentities2ascii"): return html.unescape(convertValue)
if(convertMethod == "htmlentities2bin"):
htmldecoded = self.fromhtmlentities("htmlentities2ascii", convertValue)
return self.fromAscii("ascii2bin", htmldecoded)
if(convertMethod == "htmlentities2hex"):
htmldecoded = self.fromhtmlentities("htmlentities2ascii", convertValue)
return self.fromAscii("ascii2hex", htmldecoded)
if(convertMethod == "htmlentities2base64"):
htmldecoded = self.fromhtmlentities("htmlentities2ascii", convertValue)
return self.fromAscii("ascii2base64", htmldecoded)
if(convertMethod == "htmlentities2decimal"):
htmldecoded = self.fromhtmlentities("htmlentities2ascii", convertValue)
return self.fromAscii("ascii2dec", htmldecoded)
if(convertMethod == "htmlentities2rot13"):
htmldecoded = self.fromhtmlentities("htmlentities2ascii", convertValue)
return self.fromAscii("ascii2rot13", htmldecoded)
if(convertMethod == "htmlentities2rot47"):
htmldecoded = self.fromhtmlentities("htmlentities2ascii", convertValue)
return self.fromAscii("ascii2rot47", htmldecoded)
if(convertMethod == "htmlentities2urlencoded"):
htmldecoded = self.fromhtmlentities("htmlentities2ascii", convertValue)
return self.fromAscii("ascii2urlencode", htmldecoded)
def valueErrorMsg(self, convertMethod):
layout = [
[sg.Image(data=errorImgData, size=(350,75))],
[sg.Text("* ERROR *", size=(290, 1), justification="center", font=("Arial", 14, "bold"), text_color="#ff4265")],
[sg.Text("Invalid {} value detected.".format(convertMethod), size=(290, 1), justification="center", font=("Arial", 12))],
]
sg.Window("Error", layout, size=(350, 175), finalize=True)
class Updatehandler():
def __init__(self, sgThemeGlobal):
print("[Info] Trying to download mtt updated file from official mtt github repo: %s"%(mttGithubUpdateURL))
try:
res = requests.get(mttGithubUpdateURL)
if(res.status_code >= 400):
print("[Error] Download update file ended up with an error code {}. Please inform this issue: https://github.com/shafdo/Mini-Text-Toolkit".format(res.status_code))
layout = [
[sg.Image(data=errorImgData, size=(415,100))],
[sg.Text("Error while downloading the update file.".format(res.status_code), size=(175, 1), justification="center", font=("Arial", 14, "bold"), text_color="#ff4265")],
[sg.Text("Please read terminal logs for more info.", size=(175, 1), justification="center", font=("Arial", 12, "bold"), text_color="#ccc" if (sgThemeGlobal == "Dark") else "#333")],
]
elif('version = "{}"'.format(version).encode() not in res.content):
with open(os.path.join(currentDir, "mtt.py"), "wb") as f:
f.write(res.content)
f.close()
layout = [
[sg.Image(data=tickImgData, size=(415,100))],
[sg.Text("Sucessfully Updated", size=(175, 1), justification="center", font=("Arial", 14, "bold"), text_color="#27e800" if (sgThemeGlobal == "Dark") else "#1fbd00")],
[sg.Text("Please reload MTT.", size=(175, 1), justification="center", font=("Arial", 13, "bold"), text_color="#ccc" if (sgThemeGlobal == "Dark") else "#333")],
]
else:
layout = [
[sg.Image(data=tickImgData, size=(415,100))],
[sg.Text("MTT already upto date.", size=(175, 1), justification="center", font=("Arial", 14, "bold"), text_color="#27e800" if (sgThemeGlobal == "Dark") else "#1fbd00")],
]
except(requests.exceptions.ConnectionError):
print("[Error] Cannot download file. Please check your network connection.")
layout = [
[sg.Image(data=errorImgData, size=(415,100))],
[sg.Text("Cannot download file", size=(175, 1), justification="center", font=("Arial", 14, "bold"), text_color="#ff4265")],
[sg.Text("Please check your network connection.", size=(175, 1), justification="center", font=("Arial", 12, "bold"), text_color="#ccc" if (sgThemeGlobal == "Dark") else "#333")],
]
sg.Window("Prompt", layout, size=(415, 200), finalize=True)
class SetupGUI():
def __init__(self):
# Setup Windows
window = self.windowSetup()
sgThemeGlobal = "Dark"
# Event Loop
while True:
event, values = window.read()
# print(event) # Debug Application events & Keystroke events
# Screen Closed
if event in ("None", sg.WIN_CLOSED, "e:69") or "_exit_" in event:
break
# Theme Change
elif(event == "Light::_light_"):
window.close()
window = self.windowSetup("Default1")
sgThemeGlobal = "Default1"
pass
elif(event == "Dark::_dark_"):
window.close()
window = self.windowSetup()
sgThemeGlobal = "Dark"
pass
# Help Tab
elif(event == "About::_about_"):
if(sgThemeGlobal == "Dark"):
layout = [
[sg.Image(data=aboutImgData, size=(350,75))],
[sg.Text("Mini Text Toolkit (MTT)", size=(290, 1), justification="center", font=("Arial", 14, "bold"), text_color="#ebd234")],
[sg.Text("Version {}".format(version), size=(290, 1), justification="center", font=("Arial", 12))],
[],
[sg.Text("Created By: ShaFdo", size=(290, 1), justification="center", font=("Arial", 12))],
]
sg.Window("About", layout, size=(350, 200), finalize=True)
else:
layout = [
[sg.Image(data=aboutImgData, size=(350,75))],
[sg.Text("Mini Text Toolkit (MTT)", size=(290, 1), justification="center", font=("Arial", 14, "bold"), text_color="#d4bf00")],
[sg.Text("Version {}".format(version), size=(290, 1), justification="center", font=("Arial", 12))],
[],
[sg.Text("Created By: ShaFdo", size=(290, 1), justification="center", font=("Arial", 12))],
]
sg.Window("About", layout, size=(350, 200), finalize=True)
elif("::_update_" in event):
Updatehandler(sgThemeGlobal)
# View History Options
elif("_history_" in event or "h:72" in event):
getDataDict = historyLogger().display(conn)
getDataSortedList = sorted(getDataDict.items(), key = lambda x:datetime.strptime(x[0], '%b-%d-%Y'), reverse=True)
content = ""
for row in getDataSortedList:
content += "<div class='row'><h2>{}</h2><div class='para-wrapper'>".format(row[0])
for data in row[1]:
id, time, fromType, value = data
content += "<p><span class='green-heading'>Time: </span> <span class='time-value'>{}</span> <br><span class='green-heading'>Convert From: </span> <span class='convert-from-value'>{}</span> <br> <span class='green-heading'>Value: </span> <span class='convert-value'>{}</span></p><hr class='divider'>".format(time, fromType, value)
content += "</div></div>"
historyLogger().webTempFile(tempFolderPath, content)
elif("_historyclear_" in event):
# Start From here
isHistoryCleared = historyLogger().resetDB(conn)
if(isHistoryCleared):
layout = [
[sg.Image(data=tickImgData, size=(350,100))],
[sg.Text("Operation Successful", size=(290, 1), justification="center", font=("Arial", 14, "bold"), text_color="#27e800" if (sgThemeGlobal == "Dark") else "#1fbd00")],
]
sg.Window("Prompt", layout, size=(350, 175), finalize=True)
# Continue back to the top from here
continue
layout = [
[sg.Image(data=errorImgData, size=(350,100))],
[sg.Text("Operation Failed", size=(175, 1), justification="center", font=("Arial", 14, "bold"), text_color="#ff4265")],
]
sg.Window("Prompt", layout, size=(350, 175), finalize=True)
# Clear Feilds events options
elif("_clear_" in event or "r:82" in event):
window['_asciiTextBox_'].Update('')
window['_binTextBox_'].Update('')
window['_hexTextBox_'].Update('')
window['_base64TextBox_'].Update('')
window['_decimalTextBox_'].Update('')
window['_rot13TextBox_'].Update('')
window['_rot47TextBox_'].Update('')
window['_urlEncodedTextBox_'].Update('')
window['_htmlEntitiesTextBox_'].Update('')
# Go events
elif("_go_" in event or "g:71" in event):
convertor = Convertor()
# Ascii => X
if(len(values["_asciiTextBox_"]) > 1):
val = values["_asciiTextBox_"].strip("\n")
historyLogger().log(conn, "ascii", val)
# Ascii => Bin
window["_binTextBox_"].Update(convertor.fromAscii("ascii2bin", val))
# Ascii => Hex
window["_hexTextBox_"].Update(convertor.fromAscii("ascii2hex", val))
# Ascii => Base64
window["_base64TextBox_"].Update(convertor.fromAscii("ascii2base64", val))
# Ascii => Decimal
window["_decimalTextBox_"].Update(convertor.fromAscii("ascii2dec", val))
# Ascii => Rot13
window["_rot13TextBox_"].Update(convertor.fromAscii("ascii2rot13", val))
# Ascii => Rot47
window["_rot47TextBox_"].Update(convertor.fromAscii("ascii2rot47", val))
# Ascii => UrlEncode
window["_urlEncodedTextBox_"].Update(convertor.fromAscii("ascii2urlencode", val))
# Ascii => HtmlEntities
window["_htmlEntitiesTextBox_"].Update(convertor.fromAscii("ascii2htmlentities", val))
# Binary => X
elif(len(values["_binTextBox_"]) > 1):
val = values["_binTextBox_"].strip("\n").replace(" ", "")
historyLogger().log(conn, "binary", val)
try:
# Bin => Ascii
window["_asciiTextBox_"].Update(convertor.fromBin("bin2ascii", val))
# Bin => Hex
window["_hexTextBox_"].Update(convertor.fromBin("bin2hex", val))
# Bin => Base64
window["_base64TextBox_"].Update(convertor.fromBin("bin2base64", val))
# Bin => Decimal
window["_decimalTextBox_"].Update(convertor.fromBin("bin2decimal", val))
# Bin => Rot13
window["_rot13TextBox_"].Update(convertor.fromBin("bin2rot13", val))
# Bin => Rot47
window["_rot47TextBox_"].Update(convertor.fromBin("bin2rot47", val))
# Bin => URLEncoded
window["_urlEncodedTextBox_"].Update(convertor.fromBin("bin2urlencode", val))
# Bin => HTMLEntities
window["_htmlEntitiesTextBox_"].Update(convertor.fromBin("bin2htmlentities", val))
except(ValueError):
convertor.valueErrorMsg("binary")
# Hex => X
elif(len(values["_hexTextBox_"]) > 1):
val = values["_hexTextBox_"].strip("\n").replace(" ", "").replace("0x", "")
historyLogger().log(conn, "hex", val)
try:
# Hex => Ascii
window["_asciiTextBox_"].Update(convertor.fromHex("hex2ascii", val))
# Hex => Bin
window["_binTextBox_"].Update(convertor.fromHex("hex2bin", val))
# Hex => base64
window["_base64TextBox_"].Update(convertor.fromHex("hex2base64", val))
# Hex => Decimal
window["_decimalTextBox_"].Update(convertor.fromHex("hex2decimal", val))
# Hex => Rot13
window["_rot13TextBox_"].Update(convertor.fromHex("hex2rot13", val))
# Hex => Rot47
window["_rot47TextBox_"].Update(convertor.fromHex("hex2rot47", val))
# Hex => URLEncoded
window["_urlEncodedTextBox_"].Update(convertor.fromHex("hex2urlencode", val))
# Hex => HTMLEntities
window["_htmlEntitiesTextBox_"].Update(convertor.fromHex("hex2htmlentities", val))
except(ValueError):
convertor.valueErrorMsg("hex")
# Base64 => X
elif(len(values["_base64TextBox_"]) > 1):
val = values["_base64TextBox_"].strip("\n").replace(" ", "")
historyLogger().log(conn, "base64", val)
try:
# Base64 => Ascii
window["_asciiTextBox_"].Update(convertor.fromBase64("base642ascii", val))
# Base64 => Bin
window["_binTextBox_"].Update(convertor.fromBase64("base642bin", val))
# Base64 => Hex
window["_hexTextBox_"].Update(convertor.fromBase64("base642hex", val))
# Base64 => Decimal
window["_decimalTextBox_"].Update(convertor.fromBase64("base642decimal", val))
# Base64 => Rot13
window["_rot13TextBox_"].Update(convertor.fromBase64("base642rot13", val))
# Base64 => Rot47
window["_rot47TextBox_"].Update(convertor.fromBase64("base642rot47", val))
# Base64 => UrlEncoded
window["_urlEncodedTextBox_"].Update(convertor.fromBase64("base642urlencoded", val))
# Base64 => HTMLEntities
window["_htmlEntitiesTextBox_"].Update(convertor.fromBase64("base642htmlentities", val))
except(ValueError):
convertor.valueErrorMsg("Base64")
# Decimal => X
elif(len(values["_decimalTextBox_"]) > 1):
val = values["_decimalTextBox_"].strip("\n")
historyLogger().log(conn, "decimal", val)
try:
# Decimal => Ascii
window["_asciiTextBox_"].Update(convertor.fromdec("decimal2ascii", val))
# Decimal => Binary
window["_binTextBox_"].Update(convertor.fromdec("decimal2bin", val))
# Decimal => Hex
window["_hexTextBox_"].Update(convertor.fromdec("decimal2hex", val))
# Decimal => Base64
window["_base64TextBox_"].Update(convertor.fromdec("decimal2base64", val))
# Decimal => Rot13
window["_rot13TextBox_"].Update(convertor.fromdec("decimal2rot13", val))
# Decimal => Rot47
window["_rot47TextBox_"].Update(convertor.fromdec("decimal2rot47", val))
# Decimal => UrlEncoded
window["_urlEncodedTextBox_"].Update(convertor.fromdec("decimal2urlencoded", val))
# Decimal => HTMLEntities
window["_htmlEntitiesTextBox_"].Update(convertor.fromdec("decimal2htmlentities", val))
except(ValueError):
convertor.valueErrorMsg("decimal")
# Rot13 => X
elif(len(values["_rot13TextBox_"]) > 1):
val = values["_rot13TextBox_"].strip("\n").replace(" ", "")
historyLogger().log(conn, "rot13", val)
try:
# Rot13 => Ascii
window["_asciiTextBox_"].Update(convertor.fromrot13("rot132ascii", val))
# Rot13 => Binary
window["_binTextBox_"].Update(convertor.fromrot13("rot132bin", val))
# Rot13 => Hex
window["_hexTextBox_"].Update(convertor.fromrot13("rot132hex", val))
# Rot13 => Base64
window["_base64TextBox_"].Update(convertor.fromrot13("rot132base64", val))
# Rot13 => Decimal
window["_decimalTextBox_"].Update(convertor.fromrot13("rot132decimal", val))
# Rot13 => Rot47
window["_rot47TextBox_"].Update(convertor.fromrot13("rot132rot47", val))
# Rot13 => URLEncoded
window["_urlEncodedTextBox_"].Update(convertor.fromrot13("rot132urlencoded", val))
# Rot13 => HTMLEntities
window["_htmlEntitiesTextBox_"].Update(convertor.fromrot13("rot132htmlentities", val))
except(ValueError):
convertor.valueErrorMsg("rot13")
# Rot47 => X
elif(len(values["_rot47TextBox_"]) > 1):
val = values["_rot47TextBox_"].strip("\n").replace(" ", "")
historyLogger().log(conn, "rot47", val)
try:
# Rot47 => Ascii
window["_asciiTextBox_"].Update(convertor.fromrot47("rot472ascii", val))
# Rot47 => Binary
window["_binTextBox_"].Update(convertor.fromrot47("rot472bin", val))
# Rot47 => Hex
window["_hexTextBox_"].Update(convertor.fromrot47("rot472hex", val))
# Rot47 => Base64
window["_base64TextBox_"].Update(convertor.fromrot47("rot472base64", val))
# Rot47 => Decimal
window["_decimalTextBox_"].Update(convertor.fromrot47("rot472decimal", val))
# Rot47 => Rot13
window["_rot13TextBox_"].Update(convertor.fromrot47("rot472rot13", val))
# Rot47 => URLEncoded
window["_urlEncodedTextBox_"].Update(convertor.fromrot47("rot472urlencoded", val))
# Rot47 => HTMLEntities
window["_htmlEntitiesTextBox_"].Update(convertor.fromrot47("rot472htmlentities", val))
except(ValueError):
convertor.valueErrorMsg("rot47")
# URLEncoded => X
elif(len(values["_urlEncodedTextBox_"]) > 1):
val = values["_urlEncodedTextBox_"].strip("\n").replace(" ", "")
historyLogger().log(conn, "rot47", val)
try:
# URLEncoded => Ascii
window["_asciiTextBox_"].Update(convertor.fromurlencoded("urlencoded2ascii", val))
# URLEncoded => Binary
window["_binTextBox_"].Update(convertor.fromurlencoded("urlencoded2bin", val))
# URLEncoded => Hex
window["_hexTextBox_"].Update(convertor.fromurlencoded("urlencoded2hex", val))
# URLEncoded => Base64
window["_base64TextBox_"].Update(convertor.fromurlencoded("urlencoded2base64", val))
# URLEncoded => Decimal
window["_decimalTextBox_"].Update(convertor.fromurlencoded("urlencoded2decimal", val))
# URLEncoded => Rot13
window["_rot13TextBox_"].Update(convertor.fromurlencoded("urlencoded2rot13", val))
# URLEncoded => Rot47
window["_rot47TextBox_"].Update(convertor.fromurlencoded("urlencoded2rot47", val))
# URLEncoded => HTMLEntities
window["_htmlEntitiesTextBox_"].Update(convertor.fromurlencoded("urlencoded2htmlentities", val))
except(ValueError):
convertor.valueErrorMsg("url encoded")
# HTMLEntities => X
elif(len(values["_htmlEntitiesTextBox_"]) > 1):
val = values["_htmlEntitiesTextBox_"].strip("\n").replace(" ", "")
historyLogger().log(conn, "rot47", val)
try:
# HTMLEntities => Ascii
window["_asciiTextBox_"].Update(convertor.fromhtmlentities("htmlentities2ascii", val))
# HTMLEntities => Binary
window["_binTextBox_"].Update(convertor.fromhtmlentities("htmlentities2bin", val))
# HTMLEntities => Hex
window["_hexTextBox_"].Update(convertor.fromhtmlentities("htmlentities2hex", val))
# HTMLEntities => Base64
window["_base64TextBox_"].Update(convertor.fromhtmlentities("htmlentities2base64", val))
# HTMLEntities => Decimal
window["_decimalTextBox_"].Update(convertor.fromhtmlentities("htmlentities2decimal", val))
# HTMLEntities => Rot13
window["_rot13TextBox_"].Update(convertor.fromhtmlentities("htmlentities2rot13", val))
# HTMLEntities => ROT47
window["_rot47TextBox_"].Update(convertor.fromhtmlentities("htmlentities2rot47", val))
# HTMLEntities => URLEncoded
window["_urlEncodedTextBox_"].Update(convertor.fromhtmlentities("htmlentities2urlencoded", val))
except(ValueError):
convertor.valueErrorMsg("html entity")
else:
layout = [
[sg.Image(data=errorImgData, size=(350,75))],
[sg.Text("* ERROR *", size=(290, 1), justification="center", font=("Arial", 14, "bold"), text_color="#ff4265")],
[sg.Text("No Value Detected.", size=(290, 1), justification="center", font=("Arial", 12))],
]
sg.Window("Error", layout, size=(350, 175), finalize=True)
# Copy text event options
elif("TextBoxCopy" in event):
if("_asciiTextBoxCopy_" == event): self.copy2clipboard(values["_asciiTextBox_"], "Ascii", sgThemeGlobal)
if("_binTextBoxCopy_" == event): self.copy2clipboard(values["_binTextBox_"], "Binary", sgThemeGlobal)
if("_hexTextBoxCopy_" == event): self.copy2clipboard(values["_hexTextBox_"], "Hex", sgThemeGlobal)
if("_base64TextBoxCopy_" == event): self.copy2clipboard(values["_base64TextBox_"], "Base64", sgThemeGlobal)
if("_decimalTextBoxCopy_" == event): self.copy2clipboard(values["_decimalTextBox_"], "Decimal", sgThemeGlobal)
if("_rot13TextBoxCopy_" == event): self.copy2clipboard(values["_rot13TextBox_"], "Rot13", sgThemeGlobal)
if("_rot47TextBoxCopy_" == event): self.copy2clipboard(values["_rot47TextBox_"], "Rot47", sgThemeGlobal)
if("_urlEncodedTextBoxCopy_" == event): self.copy2clipboard(values["_urlEncodedTextBox_"], "URL Encoded", sgThemeGlobal)
if("_htmlEntitiesTextBoxCopy_" == event): self.copy2clipboard(values["_htmlEntitiesTextBox_"], "HTML Entity", sgThemeGlobal)
window.close()
conn.close()
historyLogger().removeTempFolder(tempFolderPath)
print("\n[Exit Note] Thank you for trying out mtt. Have a good day :).")
def windowSetup(self, theme="Dark"):
# Set provided theme
sgThemeGlobal = theme
sg.theme(theme)
transparent = sg.LOOK_AND_FEEL_TABLE[theme]['BACKGROUND']
# Fonts & Colors
fontHeading = ("Terminal", 15)
fontLog = ("Arial", 11, "bold")
fontTextBox = ("Arial", 14)
fontColors = {
"lightColor1": "#a3a8ff",
"lightColor2": "#ffc742",
"lightColor3": "#00EAD3",
"lightColor4": "#88FFF7",
"lightColor5": "#ff7abb",
#########################
"darkColor1": "#4f10e0",
"darkColor2": "#ed00d5",
"darkColor3": "#e37900",
"darkColor4": "#00c0c7",
"darkColor5": "#15c21e",
#########################
}
# Setup menu
menu_stc = [
[
"Options",
[
"GO [Ctrl+G]::_go_",
"Reset Fields [Ctrl+R]::_clear_",
"Theme",
["Light::_light_", "Dark::_dark_"],
"Exit [Ctrl+E]::_exit_",
],
],
[
"History",
[
"View History [Ctrl+H]::_history_",
"Clear History ::_historyclear_",
]
],
[
"Help",
[
"Check for updates::_update_",
"About::_about_",
]
]
]
# Lay the stuff out accordingly
layout = [
[sg.Menu(menu_stc)],
[sg.Text('', size=(18, 1)), sg.Text('Ascii', size=(5, 1), justification="center", font=fontHeading), sg.Button('', key='_asciiTextBoxCopy_', image_data=copy2clipboardImgData, border_width=0, button_color=(transparent,transparent)), sg.Text('', size=(38, 1)), sg.Text('Binary', size=(6, 1), justification="center", font=fontHeading), sg.Button('', key='_binTextBoxCopy_', image_data=copy2clipboardImgData, border_width=0, button_color=(transparent,transparent)), sg.Text('', size=(35, 1)),sg.Text('Hexadecimal', size=(11, 1), justification="center", font=fontHeading), sg.Button('', key='_hexTextBoxCopy_', image_data=copy2clipboardImgData, border_width=0, button_color=(transparent,transparent))],
[sg.Multiline(size=(35, 7), key='_asciiTextBox_', font=fontTextBox, text_color=fontColors["lightColor5"] if(sgThemeGlobal == "Dark") else fontColors["darkColor5"]), sg.Multiline(size=(35, 7), key='_binTextBox_', font=fontTextBox, text_color=fontColors["lightColor1"] if(sgThemeGlobal == "Dark") else fontColors["darkColor1"]), sg.Multiline(size=(35, 7), key='_hexTextBox_', font=fontTextBox, text_color=fontColors["lightColor2"] if(sgThemeGlobal == "Dark") else fontColors["darkColor2"])],
[sg.Text('', size=(18, 1)), sg.Text('Base64', size=(6, 1), justification="center", font=fontHeading), sg.Button('', key='_base64TextBoxCopy_', image_data=copy2clipboardImgData, border_width=0, button_color=(transparent,transparent)), sg.Text("", size=(34, 1)), sg.Text('Decimal', size=(8, 1), justification="center", font=fontHeading), sg.Button('', key='_decimalTextBoxCopy_', image_data=copy2clipboardImgData, border_width=0, button_color=(transparent,transparent)), sg.Text("", size=(36,1)), sg.Text('Rot13', size=(5, 1), justification="center", font=fontHeading), sg.Button('', key='_rot13TextBoxCopy_', image_data=copy2clipboardImgData, border_width=0, button_color=(transparent,transparent))],
[sg.Multiline(size=(35, 7), key='_base64TextBox_', font=fontTextBox, text_color=fontColors["lightColor2"] if(sgThemeGlobal == "Dark") else fontColors["darkColor2"]), sg.Multiline(size=(35, 7), key='_decimalTextBox_', font=fontTextBox, text_color=fontColors["lightColor5"] if(sgThemeGlobal == "Dark") else fontColors["darkColor5"]), sg.Multiline(size=(35, 7), key='_rot13TextBox_', font=fontTextBox, text_color=fontColors["lightColor3"] if(sgThemeGlobal == "Dark") else fontColors["darkColor3"])],
[sg.Text('', size=(18,1)), sg.Text('Rot47', size=(5, 1), justification="center", font=fontHeading), sg.Button('', key='_rot47TextBoxCopy_', image_data=copy2clipboardImgData, border_width=0, button_color=(transparent,transparent)), sg.Text("", size=(33, 1)), sg.Text('URL Encoded', size=(11, 1), justification="center", font=fontHeading), sg.Button('', key='_urlEncodedTextBoxCopy_', image_data=copy2clipboardImgData, border_width=0, button_color=(transparent,transparent)), sg.Text("", size=(28,1)), sg.Text('HTML Entities', size=(13, 1), justification="center", font=fontHeading), sg.Button('', key='_htmlEntitiesTextBoxCopy_', image_data=copy2clipboardImgData, border_width=0, button_color=(transparent,transparent))],
[sg.Multiline(size=(35, 7), key='_rot47TextBox_', font=fontTextBox, text_color=fontColors["lightColor5"] if(sgThemeGlobal == "Dark") else fontColors["darkColor5"]), sg.Multiline(size=(35, 7), key='_urlEncodedTextBox_', font=fontTextBox, text_color=fontColors["lightColor3"] if(sgThemeGlobal == "Dark") else fontColors["darkColor3"]), sg.Multiline(size=(35, 7), key='_htmlEntitiesTextBox_', font=fontTextBox, text_color=fontColors["lightColor1"] if(sgThemeGlobal == "Dark") else fontColors["darkColor1"])],
[sg.Button('GO [Ctrl+G]', size=(25, 1), key='_go_'), sg.Button('Reset Fields [Ctrl+R]', size=(25, 1), key="_clear_")]
]
return sg.Window("Mini Text Toolkit (MTT)", layout, finalize=True, return_keyboard_events=True)
def copy2clipboard(self, value2copy, fromType, sgThemeGlobal):
try:
pyperclip.copy(value2copy)
layout = [
[sg.Image(data=tickImgData, size=(415,100))],
[sg.Text("{} value copied successfully.".format(fromType), size=(175, 1), justification="center", font=("Arial", 14, "bold"), text_color="#27e800" if (sgThemeGlobal == "Dark") else "#1fbd00")],
[sg.Text("Prompt closing in 5", key="_copy2clipboardcounter_", size=(175, 1), justification="center", font=("Arial", 13, "bold"), text_color="#ccc" if (sgThemeGlobal == "Dark") else "#333")],
]
except:
layout = [
[sg.Image(data=errorImgData, size=(415,100))],
[sg.Text("{} value failed to copy.".format(fromType), size=(175, 1), justification="center", font=("Arial", 14, "bold"), text_color="#ff4265")],
[sg.Text("Prompt closing in 5", key="_copy2clipboardcounter_", size=(175, 1), justification="center", font=("Arial", 13, "bold"), text_color="#ccc")],
]
copyResultsWindow = sg.Window("Prompt", layout, size=(415, 200), finalize=True)
start = round(time.time() % 60)
while 1:
diff = round(time.time() % 60) - start
e, v = copyResultsWindow.read(timeout=10)
if(diff >= 5 or e == None): break
copyResultsWindow['_copy2clipboardcounter_'].update("Prompt closing in {}".format(5-diff))
copyResultsWindow.close()
if (__name__ == "__main__"):
setupgui = SetupGUI()