Quicksilver Cipher Suite Python GUI
👤 Sharing: AI
import tkinter as tk
from tkinter import ttk
import random
import hashlib
import base64
from cryptography.fernet import Fernet
class CipherSuite:
def __init__(self, master):
self.master = master
master.title("Quicksilver Cipher Suite")
master.geometry("600x400")
self.notebook = ttk.Notebook(master)
self.notebook.pack(pady=10, padx=10, expand=True, fill="both")
# Tabs
self.hash_tab = ttk.Frame(self.notebook)
self.encryption_tab = ttk.Frame(self.notebook)
self.notebook.add(self.hash_tab, text="Hashing")
self.notebook.add(self.encryption_tab, text="Encryption")
self.create_hash_tab()
self.create_encryption_tab()
# Detail Button
self.detail_button = tk.Button(master, text="Details", command=self.show_details)
self.detail_button.pack(pady=5)
def create_hash_tab(self):
# Input
self.hash_label = tk.Label(self.hash_tab, text="Enter text to hash:")
self.hash_label.pack(pady=5)
self.hash_entry = tk.Entry(self.hash_tab, width=50)
self.hash_entry.pack(pady=5)
# Algorithm Selection
self.hash_algorithm_label = tk.Label(self.hash_tab, text="Select Hashing Algorithm:")
self.hash_algorithm_label.pack(pady=5)
self.hash_algorithm_options = ["MD5", "SHA256", "SHA512"]
self.hash_algorithm_var = tk.StringVar(value=self.hash_algorithm_options[1])
self.hash_algorithm_dropdown = tk.OptionMenu(self.hash_tab, self.hash_algorithm_var, *self.hash_algorithm_options)
self.hash_algorithm_dropdown.pack(pady=5)
# Hash Button
self.hash_button = tk.Button(self.hash_tab, text="Generate Hash", command=self.generate_hash)
self.hash_button.pack(pady=10)
# Output
self.hash_output_label = tk.Label(self.hash_tab, text="Generated Hash:")
self.hash_output_label.pack(pady=5)
self.hash_output_text = tk.Text(self.hash_tab, height=3, width=60)
self.hash_output_text.pack(pady=5)
def create_encryption_tab(self):
# Input
self.encrypt_label = tk.Label(self.encryption_tab, text="Enter text to encrypt/decrypt:")
self.encrypt_label.pack(pady=5)
self.encrypt_entry = tk.Entry(self.encryption_tab, width=50)
self.encrypt_entry.pack(pady=5)
# Key Input
self.key_label = tk.Label(self.encryption_tab, text="Enter Encryption Key (or generate one):")
self.key_label.pack(pady=5)
self.key_entry = tk.Entry(self.encryption_tab, width=50)
self.key_entry.pack(pady=5)
self.generate_key_button = tk.Button(self.encryption_tab, text="Generate Key", command=self.generate_key)
self.generate_key_button.pack(pady=5)
# Encryption/Decryption Buttons
self.encrypt_button = tk.Button(self.encryption_tab, text="Encrypt", command=self.encrypt_text)
self.encrypt_button.pack(pady=10, side=tk.LEFT, padx=5)
self.decrypt_button = tk.Button(self.encryption_tab, text="Decrypt", command=self.decrypt_text)
self.decrypt_button.pack(pady=10, side=tk.LEFT, padx=5)
# Output
self.encrypt_output_label = tk.Label(self.encryption_tab, text="Encrypted/Decrypted Text:")
self.encrypt_output_label.pack(pady=5)
self.encrypt_output_text = tk.Text(self.encryption_tab, height=3, width=60)
self.encrypt_output_text.pack(pady=5)
def generate_hash(self):
text = self.hash_entry.get()
algorithm = self.hash_algorithm_var.get().lower()
if algorithm == "md5":
hashed_text = hashlib.md5(text.encode()).hexdigest()
elif algorithm == "sha256":
hashed_text = hashlib.sha256(text.encode()).hexdigest()
elif algorithm == "sha512":
hashed_text = hashlib.sha512(text.encode()).hexdigest()
else:
hashed_text = "Invalid algorithm"
self.hash_output_text.delete("1.0", tk.END)
self.hash_output_text.insert(tk.END, hashed_text)
def generate_key(self):
key = Fernet.generate_key().decode()
self.key_entry.delete(0, tk.END)
self.key_entry.insert(0, key)
def encrypt_text(self):
text = self.encrypt_entry.get()
key = self.key_entry.get()
try:
f = Fernet(key.encode())
encrypted_text = f.encrypt(text.encode()).decode()
self.encrypt_output_text.delete("1.0", tk.END)
self.encrypt_output_text.insert(tk.END, encrypted_text)
except Exception as e:
self.encrypt_output_text.delete("1.0", tk.END)
self.encrypt_output_text.insert(tk.END, f"Error: {e}")
def decrypt_text(self):
text = self.encrypt_entry.get()
key = self.key_entry.get()
try:
f = Fernet(key.encode())
decrypted_text = f.decrypt(text.encode()).decode()
self.encrypt_output_text.delete("1.0", tk.END)
self.encrypt_output_text.insert(tk.END, decrypted_text)
except Exception as e:
self.encrypt_output_text.delete("1.0", tk.END)
self.encrypt_output_text.insert(tk.END, f"Error: {e}")
def show_details(self):
details_window = tk.Toplevel(self.master)
details_window.title("Program Details")
details_text = tk.Text(details_window, height=15, width=70)
details_text.pack(pady=10, padx=10)
details_text.insert(tk.END, """
Quicksilver Cipher Suite is a versatile tool designed to provide basic cryptographic functions.
Key Features:
* Hashing: Generate cryptographic hashes of text using MD5, SHA256, and SHA512 algorithms. Hashing is one-way; it's impossible to recover the original text from its hash.
* Symmetric Encryption: Encrypt and decrypt text using the Fernet library (AES encryption). Symmetric encryption uses the same key for both encryption and decryption. Keep your key safe!
How to Use:
1. Hashing: Select the 'Hashing' tab. Enter the text you want to hash. Choose the desired hashing algorithm from the dropdown menu. Click 'Generate Hash' to create the hash. The resulting hash will be displayed below.
2. Encryption/Decryption: Select the 'Encryption' tab. Enter the text you want to encrypt or decrypt. Enter the encryption key in the 'Encryption Key' field. You can generate a random key by clicking the 'Generate Key' button. Click 'Encrypt' to encrypt the text or 'Decrypt' to decrypt it. The result will be displayed below.
Important Security Notes:
* The MD5 hashing algorithm is considered cryptographically broken and should not be used for security-sensitive applications.
* Keep your encryption keys extremely safe. If you lose your key, you will not be able to decrypt your data.
* This tool is for educational and basic security purposes only. For production systems, use established and thoroughly vetted cryptographic libraries and practices.
""")
details_text.config(state=tk.DISABLED)
root = tk.Tk()
my_gui = CipherSuite(root)
root.mainloop()
👁️ Viewed: 6
Comments