Encrypted Private Diary App in Python
Code prompt
Local encrypted secret wish list app.
import tkinter as tk
from tkinter import ttk, messagebox, simpledialog
import json
import os
from datetime import datetime
from cryptography.fernet import Fernet
import base64
import hashlib
from PIL import Image, ImageTk, ImageDraw, ImageFont
import io
class WishListApp:
def __init__(self, root):
self.root = root
self.root.title("Velvet Whispers • Secret Wishlist")
self.root.geometry("920x680")
self.root.configure(bg="#2C1F1F")
# Warm elegant color palette
self.colors = {
"bg": "#2C1F1F",
"accent": "#D4A017", # Gold
"soft_gold": "#E8C670",
"text": "#F5E8C7",
"card": "#3A2A2A",
"entry_bg": "#4A3A3A",
"button": "#8C5F2E"
}
self.key_file = "velvet_key.key"
self.data_file = "velvet_wishes.enc"
self.cipher = None
self.wishes = []
self.setup_styles()
self.load_or_create_key()
self.create_ui()
self.load_wishes()
def setup_styles(self):
style = ttk.Style()
style.theme_use("clam")
style.configure("TFrame", background=self.colors["bg"])
style.configure("Card.TFrame", background=self.colors["card"], relief="flat")
style.configure("TLabel", background=self.colors["bg"], foreground=self.colors["text"], font=("Georgia", 11))
style.configure("Title.TLabel", background=self.colors["bg"], foreground=self.colors["soft_gold"],
font=("Georgia", 28, "bold"))
style.configure("Header.TLabel", background=self.colors["card"], foreground=self.colors["accent"],
font=("Georgia", 14, "bold"))
style.configure("TButton", background=self.colors["button"], foreground=self.colors["text"],
font=("Georgia", 10, "bold"), padding=8)
style.map("TButton", background=[("active", "#A67C4D")])
style.configure("TEntry", fieldbackground=self.colors["entry_bg"], foreground=self.colors["text"],
insertcolor=self.colors["soft_gold"], font=("Georgia", 11))
style.configure("TText", background=self.colors["entry_bg"], foreground=self.colors["text"],
font=("Georgia", 11))
def load_or_create_key(self):
if os.path.exists(self.key_file):
with open(self.key_file, "rb") as f:
self.key = f.read()
else:
self.key = Fernet.generate_key()
with open(self.key_file, "wb") as f:
f.write(self.key)
self.cipher = Fernet(self.key)
def encrypt_data(self, data):
json_str = json.dumps(data)
return self.cipher.encrypt(json_str.encode())
def decrypt_data(self, encrypted_data):
try:
decrypted = self.cipher.decrypt(encrypted_data)
return json.loads(decrypted.decode())
except:
return []
def load_wishes(self):
if os.path.exists(self.data_file):
try:
with open(self.data_file, "rb") as f:
encrypted = f.read()
self.wishes = self.decrypt_data(encrypted)
except:
self.wishes = []
else:
self.wishes = []
self.refresh_list()
def save_wishes(self):
encrypted = self.encrypt_data(self.wishes)
with open(self.data_file, "wb") as f:
f.write(encrypted)
def create_ui(self):
# Main container
main_frame = ttk.Frame(self.root, style="TFrame")
main_frame.pack(fill="both", expand=True, padx=20, pady=20)
# Header with elegant title
header = ttk.Frame(main_frame, style="TFrame")
header.pack(fill="x", pady=(0, 25))
title = ttk.Label(header, text="Velvet Whispers", style="Title.TLabel")
title.pack(side="left")
subtitle = ttk.Label(header, text="private wishes • ambiguous fantasies",
foreground="#8C5F2E", font=("Georgia", 10, "italic"))
subtitle.pack(side="left", padx=(15, 0), pady=(12, 0))
# New wish button
new_btn = tk.Button(header, text="+ NEW WISH", bg=self.colors["accent"], fg="#2C1F1F",
font=("Georgia", 11, "bold"), relief="flat", padx=18, pady=6,
command=self.add_new_wish)
new_btn.pack(side="right")
# Main content area - split view
content = ttk.Frame(main_frame, style="TFrame")
content.pack(fill="both", expand=True)
# Left: Wish list
list_frame = ttk.Frame(content, style="Card.TFrame")
list_frame.pack(side="left", fill="y", padx=(0, 15), pady=0, ipadx=10, ipady=10)
list_header = ttk.Label(list_frame, text="YOUR SECRET COLLECTION", style="Header.TLabel")
list_header.pack(pady=(15, 10), padx=20, anchor="w")
self.listbox = tk.Listbox(list_frame, bg=self.colors["card"], fg=self.colors["text"],
selectbackground=self.colors["accent"], selectforeground="#2C1F1F",
font=("Georgia", 11), relief="flat", highlightthickness=0,
activestyle="none", width=35, height=22)
self.listbox.pack(padx=20, pady=(0, 15), fill="both", expand=True)
self.listbox.bind("<<ListboxSelect>>", self.on_select)
# Scrollbar for list
scrollbar = ttk.Scrollbar(list_frame, orient="vertical", command=self.listbox.yview)
scrollbar.pack(side="right", fill="y", padx=(0, 20), pady=(0, 15))
self.listbox.config(yscrollcommand=scrollbar.set)
# Right: Detail view
self.detail_frame = ttk.Frame(content, style="Card.TFrame")
self.detail_frame.pack(side="right", fill="both", expand=True, pady=0, ipadx=25, ipady=25)
self.detail_title = ttk.Label(self.detail_frame, text="Select a wish to view",
style="Header.TLabel", foreground=self.colors["soft_gold"])
self.detail_title.pack(pady=(30, 15))
self.detail_date = ttk.Label(self.detail_frame, text="", foreground="#8C5F2E",
font=("Georgia", 9, "italic"))
self.detail_date.pack(pady=(0, 20))
self.detail_text = tk.Text(self.detail_frame, bg=self.colors["entry_bg"], fg=self.colors["text"],
font=("Georgia", 12), wrap="word", relief="flat", padx=18, pady=18,
height=14, width=45, insertbackground=self.colors["accent"])
self.detail_text.pack(padx=25, pady=10, fill="both", expand=True)
# Action buttons
btn_frame = ttk.Frame(self.detail_frame, style="TFrame")
btn_frame.pack(pady=20)
self.edit_btn = tk.Button(btn_frame, text="✎ EDIT", bg=self.colors["button"], fg=self.colors["text"],
font=("Georgia", 10, "bold"), relief="flat", padx=20, pady=6,
command=self.edit_current)
self.edit_btn.pack(side="left", padx=8)
self.delete_btn = tk.Button(btn_frame, text="🗑 DELETE", bg="#6B3A3A", fg=self.colors["text"],
font=("Georgia", 10, "bold"), relief="flat", padx=20, pady=6,
command=self.delete_current)
self.delete_btn.pack(side="left", padx=8)
# Footer hint
hint = ttk.Label(main_frame, text="All wishes are encrypted locally • Only you can read them",
foreground="#6B5A4A", font=("Georgia", 9, "italic"))
hint.pack(pady=(25, 0))
self.current_index = None
def refresh_list(self):
self.listbox.delete(0, tk.END)
for wish in self.wishes:
title = wish.get("title", "Untitled Fantasy")
date = wish.get("date", "—")
self.listbox.insert(tk.END, f"• {title} [{date}]")
def add_new_wish(self):
title = simpledialog.askstring("New Wish", "Give this secret a title:", parent=self.root)
if not title:
return
self.wishes.append({
"title": title.strip(),
"content": "",
"date": datetime.now().strftime("%b %d, %Y")
})
self.save_wishes()
self.refresh_list()
self.listbox.selection_clear(0, tk.END)
self.listbox.selection_set(len(self.wishes)-1)
self.on_select(None)
def on_select(self, event):
selection = self.listbox.curselection()
if not selection:
return
self.current_index = selection[0]
wish = self.wishes[self.current_index]
self.detail_title.config(text=wish.get("title", "Untitled"))
self.detail_date.config(text=f"Whispered on {wish.get('date', '—')}")
self.detail_text.delete("1.0", tk.END)
self.detail_text.insert("1.0", wish.get("content", ""))
def edit_current(self):
if self.current_index is None:
messagebox.showinfo("Velvet Whispers", "Please select a wish first.")
return
wish = self.wishes[self.current_index]
# Create edit dialog
edit_win = tk.Toplevel(self.root)
edit_win.title("Edit Secret")
edit_win.geometry("620x520")
edit_win.configure(bg=self.colors["bg"])
ttk.Label(edit_win, text="Title", background=self.colors["bg"],
foreground=self.colors["soft_gold"], font=("Georgia", 11, "bold")).pack(pady=(25, 5), anchor="w", padx=40)
title_entry = tk.Entry(edit_win, bg=self.colors["entry_bg"], fg=self.colors["text"],
font=("Georgia", 12), relief="flat", insertbackground=self.colors["accent"])
title_entry.insert(0, wish.get("title", ""))
title_entry.pack(padx=40, pady=(0, 15), fill="x")
ttk.Label(edit_win, text="Your Private Fantasy", background=self.colors["bg"],
foreground=self.colors["soft_gold"], font=("Georgia", 11, "bold")).pack(pady=(10, 5), anchor="w", padx=40)
content_text = tk.Text(edit_win, bg=self.colors["entry_bg"], fg=self.colors["text"],
font=("Georgia", 12), wrap="word", relief="flat", padx=15, pady=15, height=14)
content_text.insert("1.0", wish.get("content", ""))
content_text.pack(padx=40, pady=5, fill="both", expand=True)
def save_edit():
new_title = title_entry.get().strip()
if not new_title:
new_title = "Untitled Fantasy"
self.wishes[self.current_index]["title"] = new_title
self.wishes[self.current_index]["content"] = content_text.get("1.0", tk.END).strip()
self.save_wishes()
self.refresh_list()
self.on_select(None)
edit_win.destroy()
save_btn = tk.Button(edit_win, text="SAVE THIS SECRET", bg=self.colors["accent"], fg="#2C1F1F",
font=("Georgia", 12, "bold"), relief="flat", padx=30, pady=10,
command=save_edit)
save_btn.pack(pady=25)
edit_win.transient(self.root)
edit_win.grab_set()
def delete_current(self):
if self.current_index is None:
return
if messagebox.askyesno("Delete Secret", "Permanently erase this wish forever?",
icon="warning", parent=self.root):
del self.wishes[self.current_index]
self.save_wishes()
self.refresh_list()
self.detail_title.config(text="Select a wish to view")
self.detail_date.config(text="")
self.detail_text.delete("1.0", tk.END)
self.current_index = None
if __name__ == "__main__":
try:
from PIL import Image, ImageTk
except ImportError:
print("Please install Pillow: pip install pillow cryptography")
exit()
root = tk.Tk()
app = WishListApp(root)
root.mainloop()Generate Python code to develop an elegant local secret wish list app that can encrypt and save users' private wishes and ambiguous fantasies. The interface uses warm tones.
This prompt focuses on “Secret Wish List Encryption App”: Local encrypted secret wish list app. It is ready to use for code generation on HackAIGC.
Open the prompt, tap Use prompt or Copy prompt, then run it with your preferred model and settings.
The brief for “Secret Wish List Encryption App” includes elegant, warm cues. Edit the prompt to change the tone, structure, or level of detail.
Yes. Copy the prompt text, modify details, then generate again on HackAIGC.