π Auto Decrypt & Run Python Files with Stylish Tkinter GUI | FuzzuTech Tutorial
Demo :
Click Video πππ
✨ Features
-
Step-by-step guide to building the GUI
-
Explanation of XOR encryption/decryption
-
Automating script execution post-decryption
-
Downloadable source code
-
Screenshots of the application interface
-
Video tutorial embedded
Code :
1.) encrypt.py
import tkinter as tkfrom tkinter import filedialog, messageboximport os# XOR Encryption Functiondef xor_encrypt(content, key):return ''.join(chr(ord(c) ^ ord(key)) for c in content)# Select file and encryptdef encrypt_file():filepath = filedialog.askopenfilename(title="Select Python File to Encrypt",filetypes=[("Python Files", "*.py")])if not filepath:returnkey = key_entry.get()if len(key) != 1:messagebox.showerror("Invalid Key", "Please enter exactly ONE character key.")returntry:with open(filepath, "r", encoding="utf-8") as f:original_data = f.read()encrypted_data = xor_encrypt(original_data, key)output_file = os.path.splitext(filepath)[0] + "_encrypted.txt"with open(output_file, "w", encoding="utf-8") as f:f.write(encrypted_data)messagebox.showinfo("Success", f"Encrypted file saved as:\n{output_file}")except Exception as e:messagebox.showerror("Error", f"Something went wrong:\n{e}")# ---------------- GUI ----------------root = tk.Tk()root.title("π FuzzuTech File Encryptor")root.geometry("400x250")root.config(bg="#1e1e1e")root.resizable(False, False)# Headingtitle = tk.Label(root, text="π Encrypt Python File", font=("Helvetica", 16, "bold"), fg="#00FFAA", bg="#1e1e1e")title.pack(pady=20)# Key Entrytk.Label(root, text="Enter 1-Char Key:", font=("Arial", 12), fg="white", bg="#1e1e1e").pack(pady=5)key_entry = tk.Entry(root, width=10, show="*", font=("Arial", 12), justify="center")key_entry.pack(pady=5)# Buttonbtn = tk.Button(root, text="π Select & Encrypt Python File", command=encrypt_file, bg="#00FFAA", fg="black", font=("Arial", 12, "bold"), padx=10, pady=5)btn.pack(pady=25)# Footerfooter = tk.Label(root, text="Developed By Fuzzu Developer π»", font=("Arial", 10), fg="#888", bg="#1e1e1e")footer.pack(side="bottom", pady=10)root.mainloop()
2.) decrypt.py
import tkinter as tkfrom tkinter import messagebox, filedialogimport subprocessimport osimport timeimport sys# XOR Decryption Logicdef xor_decrypt(content, key):return ''.join([chr(ord(char) ^ ord(key)) for char in content])# ✅ Decrypt + Rundef start_decryption():filepath = filedialog.askopenfilename(title="Select Encrypted File",filetypes=[("Text Files", "*.txt")])if not filepath:returnkey = key_entry.get()if len(key) != 1:messagebox.showerror("Invalid Key", "Please enter exactly ONE character key.")returntry:with open(filepath, "r", encoding="utf-8") as f:encrypted_data = f.read()decrypted_data = xor_decrypt(encrypted_data, key)temp_file = "temp_decrypted_run.py"with open(temp_file, "w", encoding="utf-8") as f:f.write(decrypted_data)messagebox.showinfo("Success", "File decrypted and now running...")subprocess.run([sys.executable, temp_file], shell=True)time.sleep(1)os.remove(temp_file)print("Decrypted file deleted.")except Exception as e:messagebox.showerror("Error", f"Something went wrong:\n{e}")# ✅ Decrypt + Savedef decrypt_and_save():filepath = filedialog.askopenfilename(title="Select Encrypted File",filetypes=[("Text Files", "*.txt")])if not filepath:returnkey = key_entry.get()if len(key) != 1:messagebox.showerror("Invalid Key", "Please enter exactly ONE character key.")returntry:with open(filepath, "r", encoding="utf-8") as f:encrypted_data = f.read()decrypted_data = xor_decrypt(encrypted_data, key)output_file = filedialog.asksaveasfilename(defaultextension=".py",filetypes=[("Python Files", "*.py")],title="Save Decrypted Python File")if not output_file:returnwith open(output_file, "w", encoding="utf-8") as f:f.write(decrypted_data)messagebox.showinfo("Success", f"File decrypted and saved as:\n{output_file}")except Exception as e:messagebox.showerror("Error", f"Something went wrong:\n{e}")# ----------------- GUI -----------------root = tk.Tk()root.title("Auto Decrypt & Run / Save")root.geometry("400x350")root.config(bg="#1e1e1e")root.resizable(False, False)# Headingtitle_label = tk.Label(root, text="π Auto Decrypt & Run π₯",font=("Helvetica", 16, "bold"),fg="#FF6F61", bg="#1e1e1e")title_label.pack(pady=20)# Key Entrytk.Label(root, text="Enter 1-Char Key:",font=("Arial", 12),fg="white", bg="#1e1e1e").pack(pady=5)key_entry = tk.Entry(root, width=10, show="*",font=("Arial", 12), justify="center")key_entry.pack(pady=5)# Run Buttonprocess_btn = tk.Button(root, text="▶️ Decrypt & Run File",command=start_decryption,bg="#28a745", fg="white",font=("Arial", 12, "bold"),padx=10, pady=5)process_btn.pack(pady=10)# Save Only Buttonsave_btn = tk.Button(root, text="πΎ Decrypt & Save As .py",command=decrypt_and_save,bg="#007BFF", fg="white",font=("Arial", 12, "bold"),padx=10, pady=5)save_btn.pack(pady=5)# Footerfooter = tk.Label(root, text="Developed By Fuzzu Developer π»",font=("Arial", 10),fg="#888", bg="#1e1e1e")footer.pack(side="bottom", pady=10)root.mainloop()
3.) Demo.py
Include Your Code (Only Check Encrypt & Decrypt Using Demo.py So No any Logic in Demo.py)
Comments
Post a Comment