from tkinter import *
import pyperclip
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Criptografia")
titulo = Label(text="Criptografia",
font=("Arial", "38", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.18, rely=0.05)
sub1 = Label(text="Texto: ", font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
sub1.place(relx=0.15, rely=0.25)
Texto = StringVar()
Texto_entrada = Entry(textvariable=Texto, font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Texto_entrada.place(relx=0.4, rely=0.26, relwidth=0.53)
Texto_entrada.focus()
def limpar():
Texto_entrada.delete(0, END)
resultado_texto.config(text="")
def copiar():
texto_cifrado = resultado_texto.cget("text")
pyperclip.copy(texto_cifrado)
def app():
t = Texto.get()
texto_cifrado = ""
for i in range(0, len(t), 2):
texto_cifrado += t[i]
for i in range(1, len(t), 2):
texto_cifrado += t[i]
mensagem = f"{texto_cifrado}"
resultado_texto.config(text=mensagem)
but1 = Button(text="Mostrar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.45, relwidth=0.25, relheight=0.1)
but_limpar = Button(text="Limpar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=limpar)
but_limpar.place(relx=0.4, rely=0.45, relwidth=0.25, relheight=0.1)
but_copiar = Button(text="Copiar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=copiar)
but_copiar.place(relx=0.7, rely=0.45, relwidth=0.25, relheight=0.1)
sub2 = Label(text="Texto cifrado ", font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
sub2.place(relx=0.3, rely=0.65)
resultado_texto = Label(font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.75, relwidth=0.9, relheight=0.15)
root.mainloop()