1
+ from tkinter import *
2
+ from tkinter import messagebox
3
+
4
+ import base64
5
+ import os
6
+
7
+ def decrypt ():
8
+
9
+ password = code .get ()
10
+
11
+ if password == "1234" :
12
+ screen2 = Toplevel (screen )
13
+ screen2 .title ("Descriptador" )
14
+ screen2 .geometry ("400x200" )
15
+ screen2 .configure (bg = "#028f76" )
16
+
17
+ message = text1 .get (1.0 ,END )
18
+ decode_message = message .encode ("ascii" )
19
+ base64_bytes = base64 .b64decode (decode_message )
20
+ decrypt = base64_bytes .decode ("ascii" )
21
+
22
+ Label (screen2 , text = "Decriptado" , font = "Futura 12" , fg = "white" , bg = "#028f76" ).place (x = 10 ,y = 0 )
23
+ text2 = Text (screen2 ,font = "Futura 12" , bg = "white" , relief = GROOVE , wrap = WORD , bd = 0 )
24
+ text2 .place (x = 10 , y = 40 ,width = 380 ,height = 150 )
25
+
26
+ text2 .insert (END , decrypt )
27
+
28
+ elif password == "" :
29
+ messagebox .showerror ("Crypter" ,"Insira a chave de acesso!" )
30
+ elif password != "1234" :
31
+ messagebox .showerror ("Crypter" ,"chave inválida!" )
32
+
33
+ def encrypt ():
34
+ password = code .get ()
35
+
36
+ if password == "1234" :
37
+ screen1 = Toplevel (screen )
38
+ screen1 .title ("Crypter" )
39
+ screen1 .geometry ("400x200" )
40
+ screen1 .configure (bg = "#005bc5" )
41
+
42
+ message = text1 .get (1.0 ,END )
43
+ encode_message = message .encode ("ascii" )
44
+ base64_bytes = base64 .b64encode (encode_message )
45
+ encrypt = base64_bytes .decode ("ascii" )
46
+
47
+ Label (screen1 , text = "Criptografado" , font = "Futura 12" , fg = "white" , bg = "#005bc5" ).place (x = 10 ,y = 0 )
48
+ text2 = Text (screen1 ,font = "Futura 12" , bg = "white" , relief = GROOVE , wrap = WORD , bd = 0 )
49
+ text2 .place (x = 10 , y = 40 ,width = 380 ,height = 150 )
50
+
51
+ text2 .insert (END , encrypt )
52
+
53
+ elif password == "" :
54
+ messagebox .showerror ("Crypter" ,"Insira a chave de acesso!" )
55
+ elif password != "1234" :
56
+ messagebox .showerror ("Crypter" ,"Chave inválida!" )
57
+
58
+ def main_screen ():
59
+
60
+ global screen
61
+ global code
62
+ global text1
63
+
64
+ screen = Tk ()
65
+ screen .geometry ("375x398" )
66
+ screen .configure (bg = "#23192d" )
67
+
68
+ #icon
69
+ image_icon = PhotoImage (file = "./img/padlock.png" )
70
+ screen .iconphoto (False ,image_icon )
71
+
72
+ screen .title ("Crypter" )
73
+
74
+ def reset ():
75
+ code .set ("" )
76
+ text1 .delete (1.0 ,END )
77
+
78
+ Label (text = "Digite um texto para encriptar/decriptar:" , fg = "white" ,bg = "#23192d" ,font = "Futura 12 bold" ).place (x = 10 , y = 10 )
79
+ text1 = Text (font = "Futura 18" , bg = "white" , relief = GROOVE ,wrap = WORD ,bd = 0 )
80
+ text1 .place (x = 10 , y = 50 , width = 355 , height = 100 )
81
+
82
+ Label (text = "Digite a chave de acesso" , fg = "white" , bg = "#23192d" , font = "Futura 12 bold" ).place (x = 10 , y = 165 )
83
+
84
+ code = StringVar ()
85
+ Entry (textvariable = code , width = 19 , bd = 0 , font = "Futura 18" , show = "*" ).place (x = 10 , y = 200 )
86
+
87
+ Button (text = "Encriptar" , font = "Futura 9 bold" , height = "2" , width = 23 , bg = "#005bc5" , fg = "white" , bd = 0 , command = encrypt ).place (x = 10 , y = 250 )
88
+ Button (text = "Desencriptar" ,font = "Futura 9 bold" , height = "2" , width = 23 ,bg = "#005bc5" ,fg = "white" , bd = 0 , command = decrypt ).place (x = 200 , y = 250 )
89
+ Button (text = "Limpar" , font = "Futura 9 bold" , height = "2" , width = 50 ,bg = "#028f76" ,fg = "white" , bd = 0 , command = reset ).place (x = 10 , y = 300 )
90
+
91
+ screen .mainloop ()
92
+
93
+ main_screen ()
0 commit comments