Skip to content

Instantly share code, notes, and snippets.

@Monroe2662
Last active May 30, 2025 19:53
Show Gist options
  • Save Monroe2662/40c2c08381ce560d3b260c19cd789d94 to your computer and use it in GitHub Desktop.
Save Monroe2662/40c2c08381ce560d3b260c19cd789d94 to your computer and use it in GitHub Desktop.
import tkinter as tk
from tkinter import filedialog, messagebox
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
import hashlib, struct, os
PWD = "$MitnickSecure25"
SALT_LEN = 16
def derive_keys(pwd, salt):
k = hashlib.pbkdf2_hmac("sha256", pwd.encode(), salt, 200_000, dklen=64)
return k[:32], k[32:]
def crypt_xts(path, mode):
with open(path, 'rb') as f: data = f.read()
salt = data[:SALT_LEN] if mode == 'dec' else get_random_bytes(SALT_LEN)
ct = data[SALT_LEN:] if mode == 'dec' else data
k1, k2 = derive_keys(PWD, salt)
cipher = AES.new(k1 + k2, AES.MODE_XTS, tweak=struct.pack("<Q", 0) + b'\0'*8)
out = cipher.decrypt(ct) if mode == 'dec' else cipher.encrypt(ct)
out_path = path.replace('.xts', '.dec') if mode == 'dec' else path + '.xts'
with open(out_path, 'wb') as f: f.write(out if mode == 'dec' else salt + out)
messagebox.showinfo("Success", f"{'Decrypted' if mode == 'dec' else 'Encrypted'}:\n{out_path}")
class App:
def __init__(self, root):
self.path = None
root.title("AES-256-XTS Encryptor")
root.geometry("380x190")
self.splash()
tk.Button(root, text="Select File", command=self.select).pack(pady=6)
tk.Button(root, text="Encrypt", command=lambda: self.run('enc')).pack(pady=6)
tk.Button(root, text="Decrypt", command=lambda: self.run('dec')).pack(pady=6)
def splash(self):
art = """
_____ _____ _____ _____ _____
/\ \ /\ \ /\ \ /\ \ /\ \
/::\ \ /::\ \ /::\____\ /::\____\ /::\ \
/::::\ \ /::::\ \ /::::| | /::::| | \:::\ \
/::::::\ \ /::::::\ \ /:::::| | /:::::| | \:::\ \
/:::/\:::\ \ /:::/\:::\ \ /::::::| | /::::::| | \:::\ \
/:::/__\:::\ \ /:::/__\:::\ \ /:::/|::| | /:::/|::| | \:::\ \
\:::\ \:::\ \ /::::\ \:::\ \ /:::/ |::| | /:::/ |::| | /::::\ \
___\:::\ \:::\ \ /::::::\ \:::\ \ /:::/ |::|___|______ /:::/ |::|___|______ ____ /::::::\ \
/\ \:::\ \:::\ \ /:::/\:::\ \:::\ \ /:::/ |::::::::\ \ /:::/ |::::::::\ \ /\ \ /:::/\:::\ \
/::\ \:::\ \:::\____\/:::/ \:::\ \:::\____\/:::/ |:::::::::\____\/:::/ |:::::::::\____\/::\ \/:::/ \:::\____\
\:::\ \:::\ \::/ /\::/ \:::\ /:::/ /\::/ / ~~~~~/:::/ /\::/ / ~~~~~/:::/ /\:::\ /:::/ \::/ /
\:::\ \:::\ \/____/ \/____/ \:::\/:::/ / \/____/ /:::/ / \/____/ /:::/ / \:::\/:::/ / \/____/
\:::\ \:::\ \ \::::::/ / /:::/ / /:::/ / \::::::/ /
\:::\ \:::\____\ \::::/ / /:::/ / /:::/ / \::::/____/
\:::\ /:::/ / /:::/ / /:::/ / /:::/ / \:::\ \
\:::\/:::/ / /:::/ / /:::/ / /:::/ / \:::\ \
\::::::/ / /:::/ / /:::/ / /:::/ / \:::\ \
\::::/ / /:::/ / /:::/ / /:::/ / \:::\____\
\::/ / \::/ / \::/ / \::/ / \::/ /
\/____/ \/____/ \/____/ \/____/ \/____/
"""
messagebox.showinfo("SAMMI", art)
def select(self):
self.path = filedialog.askopenfilename()
if self.path: messagebox.showinfo("File", self.path)
def run(self, mode):
if not self.path: messagebox.showerror("Error", "No file selected."); return
crypt_xts(self.path, mode)
if __name__ == "__main__":
root = tk.Tk()
App(root)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment