π Fuzzu Encryptor – Python GUI for Text & File Security | CustomTkinter App
Demo :
Click Video πππ
Features:
-
Live Demo Snapshots (Add screenshots of GUI)
-
How it works: Text encryption/decryption
-
File protection workflow
-
Why this project is unique (offline + visual + secure)
-
Download code (optional GitHub link)
-
Related Shorts or projects by FuzzuTech
Code :
import customtkinter as ctk
from tkinter import filedialog, messagebox
from cryptography.fernet import Fernet
import os
# -------------------------
# Appearance and Theme
# -------------------------
ctk.set_appearance_mode("dark")
ctk.set_default_color_theme("blue")
# -------------------------
# Main App Setup
# -------------------------
app = ctk.CTk()
app.title("Fuzzu Encryptor | Modern GUI")
app.geometry("600x500")
# -------------------------
# Load or Create Key
# -------------------------
def load_or_create_key():
if os.path.exists("key.key"):
with open("key.key", "rb") as f:
return f.read()
else:
new_key = Fernet.generate_key()
with open("key.key", "wb") as f:
f.write(new_key)
return new_key
key = load_or_create_key()
cipher = Fernet(key)
# -------------------------
# Functions
# -------------------------
def encrypt_text():
plain = text_input.get("1.0", "end").strip()
if not plain:
messagebox.showwarning("Empty", "Please enter text to encrypt.")
return
encrypted = cipher.encrypt(plain.encode())
output_text.delete("1.0", "end")
output_text.insert("1.0", encrypted.decode())
def decrypt_text():
try:
cipher_text = text_input.get("1.0", "end").strip()
decrypted = cipher.decrypt(cipher_text.encode())
output_text.delete("1.0", "end")
output_text.insert("1.0", decrypted.decode())
except:
messagebox.showerror("Failed", "Decryption failed. Check input.")
def encrypt_file():
filepath = filedialog.askopenfilename()
if filepath:
with open(filepath, 'rb') as f:
data = f.read()
encrypted = cipher.encrypt(data)
savepath = filedialog.asksaveasfilename(defaultextension=".enc")
if savepath:
with open(savepath, 'wb') as f:
f.write(encrypted)
messagebox.showinfo("Success", "File encrypted and saved!")
def decrypt_file():
filepath = filedialog.askopenfilename()
if filepath:
with open(filepath, 'rb') as f:
data = f.read()
try:
decrypted = cipher.decrypt(data)
savepath = filedialog.asksaveasfilename(defaultextension=".txt")
if savepath:
with open(savepath, 'wb') as f:
f.write(decrypted)
messagebox.showinfo("Success", "File decrypted and saved!")
except:
messagebox.showerror("Failed", "Invalid file or key!")
# -------------------------
# GUI Design
# -------------------------
ctk.CTkLabel(app, text="Fuzzu Encryptor / Decryptor", font=("Arial", 22, "bold")).pack(pady=15)
text_input = ctk.CTkTextbox(app, height=100, font=("Consolas", 14))
text_input.pack(padx=20, pady=10, fill="x")
btn_frame = ctk.CTkFrame(app)
btn_frame.pack(pady=10)
ctk.CTkButton(btn_frame, text="Encrypt Text", command=encrypt_text, width=140).grid(row=0, column=0, padx=10)
ctk.CTkButton(btn_frame, text="Decrypt Text", command=decrypt_text, width=140).grid(row=0, column=1, padx=10)
file_frame = ctk.CTkFrame(app)
file_frame.pack(pady=10)
ctk.CTkButton(file_frame, text="Encrypt File", command=encrypt_file, width=140).grid(row=0, column=0, padx=10)
ctk.CTkButton(file_frame, text="Decrypt File", command=decrypt_file, width=140).grid(row=0, column=1, padx=10)
ctk.CTkLabel(app, text="Output:", font=("Arial", 16)).pack(pady=5)
output_text = ctk.CTkTextbox(app, height=100, font=("Consolas", 14))
output_text.pack(padx=20, pady=5, fill="x")
ctk.CTkLabel(app, text="π Developed by Fuzzu Developer", font=("Arial", 10)).pack(pady=10)
app.mainloop()
Comments
Post a Comment