CAESAR CYPHER ENCRYPTOR PROJECT

Опубликовано: 29 Июль 2026
на канале: Aarav Ahuja
12
3

used:
Python as the main programming language.
Tkinter for the GUI interface.
Modularized cipher logic to make it reusable.
Styling and layout techniques to make the GUI look modern, colorful, and intuitive.
What's next for Caesar Cipher Encryptor
Add a "Copy to Clipboard" button.
Add file input/output to encrypt/decrypt text files.
Implement a dark/light theme switcher.
Convert it into a web app using Flask or Streamlit.
Bundle it into a .exe or standalone app using PyInstaller for easy sharing.

CODE:
import tkinter as tk
from tkinter import ttk

Cipher logic
alphabets = [chr(i) for i in range(65, 91)] # A-Z

def caesar(encode_decode, original_text, shift_amount):
if encode_decode == "decode":
shift_amount = -int(shift_amount)
result = ""
for letter in original_text.upper():
if letter in alphabets:
new_index = (alphabets.index(letter) + shift_amount) % len(alphabets)
result += alphabets[new_index]
else:
result += letter
return result

def on_submit():
direction = direction_var.get()
text = input_text.get("1.0", tk.END).strip()
shift = shift_entry.get()

if not shift.isdigit():
output_label.config(text="❌ Enter a valid number for shift.")
return

result = caesar(direction, text, int(shift))
output_label.config(text=f"🔐 Result:\n{result}")

GUI Setup
root = tk.Tk()
root.title("Caesar Cipher")
root.geometry("700x600")
root.configure(bg="#1e1e2f") # Dark blue background

style = ttk.Style()
style.theme_use("clam")

title = tk.Label(root, text="🔐 Caesar Cipher", font=("Arial Black", 28), bg="#1e1e2f", fg="#61dafb")
title.pack(pady=20)

Direction (Encode/Decode)
direction_frame = tk.Frame(root, bg="#1e1e2f")
direction_frame.pack(pady=10)
direction_label = tk.Label(direction_frame, text="Select Action:", font=("Arial", 14), bg="#1e1e2f", fg="white")
direction_label.pack(side=tk.LEFT, padx=10)
direction_var = tk.StringVar(value="encode")
tk.Radiobutton(direction_frame, text="Encode", variable=direction_var, value="encode", font=("Arial", 12), bg="#1e1e2f", fg="white").pack(side=tk.LEFT)
tk.Radiobutton(direction_frame, text="Decode", variable=direction_var, value="decode", font=("Arial", 12), bg="#1e1e2f", fg="white").pack(side=tk.LEFT)

Input Text
input_label = tk.Label(root, text="Enter your message:", font=("Arial", 14), bg="#1e1e2f", fg="white")
input_label.pack()
input_text = tk.Text(root, height=6, width=60, font=("Courier New", 12))
input_text.pack(pady=10)

Shift Entry
shift_label = tk.Label(root, text="Shift Value:", font=("Arial", 14), bg="#1e1e2f", fg="white")
shift_label.pack()
shift_entry = tk.Entry(root, font=("Arial", 14), width=10, justify="center")
shift_entry.insert(0, "3")
shift_entry.pack(pady=5)

Submit Button
submit_btn = tk.Button(root, text="🚀 Run Cipher", command=on_submit, font=("Arial", 14, "bold"), bg="#61dafb", fg="black", width=20)
submit_btn.pack(pady=20)

Output Label
output_label = tk.Label(root, text="", font=("Consolas", 14), bg="#1e1e2f", fg="#ADFF2F", wraplength=600, justify="left")
output_label.pack(pady=10)

Run the app
root.mainloop()