Vibrant Verifier Python GUI
👤 Sharing: AI
import tkinter as tk
from tkinter import ttk
import hashlib
import os
class FileIntegrityChecker:
def __init__(self, master):
self.master = master
master.title("Vibrant Verifier: File Integrity Checker")
self.file_path = tk.StringVar()
self.algorithm = tk.StringVar(value="sha256")
ttk.Label(master, text="Select File:").grid(row=0, column=0, padx=5, pady=5, sticky=tk.W)
ttk.Entry(master, textvariable=self.file_path, width=50).grid(row=0, column=1, padx=5, pady=5)
ttk.Button(master, text="Browse", command=self.browse_file).grid(row=0, column=2, padx=5, pady=5)
ttk.Label(master, text="Hashing Algorithm:").grid(row=1, column=0, padx=5, pady=5, sticky=tk.W)
algorithm_choices = ["md5", "sha1", "sha256", "sha512"]
algorithm_dropdown = ttk.Combobox(master, textvariable=self.algorithm, values=algorithm_choices, state="readonly")
algorithm_dropdown.grid(row=1, column=1, padx=5, pady=5, sticky=tk.W)
ttk.Button(master, text="Calculate Hash", command=self.calculate_hash).grid(row=2, column=1, padx=5, pady=5)
self.hash_value = tk.StringVar()
ttk.Label(master, text="Hash Value:").grid(row=3, column=0, padx=5, pady=5, sticky=tk.W)
ttk.Entry(master, textvariable=self.hash_value, width=50, state="readonly").grid(row=3, column=1, padx=5, pady=5)
ttk.Button(master, text="Details", command=self.show_details).grid(row=4, column=1, padx=5, pady=5)
self.details_window = None
def browse_file(self):
from tkinter import filedialog
filename = filedialog.askopenfilename()
self.file_path.set(filename)
def calculate_hash(self):
file_path = self.file_path.get()
algorithm = self.algorithm.get()
if not file_path:
self.hash_value.set("Please select a file.")
return
try:
hasher = hashlib.new(algorithm)
with open(file_path, 'rb') as afile:
buf = afile.read(65536) # Read in 64kb chunks
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(65536)
self.hash_value.set(hasher.hexdigest())
except Exception as e:
self.hash_value.set(f"Error: {e}")
def show_details(self):
if self.details_window is not None:
self.details_window.destroy()
self.details_window = tk.Toplevel(self.master)
self.details_window.title("Details")
details_text = tk.Text(self.details_window, wrap=tk.WORD, width=60, height=15)
details_text.pack(padx=10, pady=10)
details = """
Vibrant Verifier is a tool designed to ensure the integrity of your files.
It calculates the cryptographic hash of a selected file using various algorithms
(MD5, SHA1, SHA256, SHA512). This hash acts as a unique fingerprint for the file.
**How to use:**
1. Click the 'Browse' button to select the file you want to verify.
2. Choose the desired hashing algorithm from the dropdown menu.
3. Click 'Calculate Hash'. The calculated hash will be displayed.
You can then compare the calculated hash with a known good hash of the file
to verify its integrity. If the hashes match, the file is likely unchanged.
If they don't match, the file has been modified or corrupted.
**Use Cases:**
* Verify downloaded files to ensure they haven't been tampered with.
* Check the integrity of archived files over time.
* Detect accidental or malicious changes to important files.
**Security Notes:**
* While MD5 and SHA1 are faster, they are considered cryptographically weak for many applications.
* SHA256 and SHA512 offer stronger security and are recommended for critical file verification.
"""
details_text.insert(tk.END, details)
details_text.config(state=tk.DISABLED) # Make it read-only
root = tk.Tk()
style = ttk.Style(root)
style.theme_use('clam') # 'clam' for a cleaner look
my_gui = FileIntegrityChecker(root)
root.mainloop()
👁️ Viewed: 5
Comments