Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- from tkinter import messagebox
- import hashlib
- from pygame import mixer
- window = tk.Tk()
- mixer.init()
- HEIGHT = 500
- WIDTH = 600
- window.title("Hashing Machine")
- global hash_pass
- def about():
- tk.messagebox.showinfo("Details", "A simple hashing software written by Allexus M. Constantino using Python 3.7")
- def type_md5():
- global hash_pass
- hash_pass = hashlib.md5()
- print(hash_pass.hexdigest())
- def type_sha256():
- global hash_pass
- hash_pass = hashlib.sha256()
- print(hash_pass.hexdigest())
- def type_sha512():
- global hash_pass
- hash_pass = hashlib.sha512()
- print(hash_pass.hexdigest())
- def type_sha3_384():
- global hash_pass
- hash_pass = hashlib.sha3_384()
- print(hash_pass.hexdigest())
- def type_sha3_256():
- global hash_pass
- hash_pass = hashlib.sha3_256()
- print(hash_pass.hexdigest())
- def hash_it(pass_entry):
- mixer.music.load("sound.mp3")
- mixer.music.play()
- var = tk.StringVar()
- global hash_pass
- if hash_btn:
- if md5:
- type_md5()
- elif sha256:
- type_sha256()
- elif sha512:
- type_sha512()
- elif sha3_384:
- type_sha3_384()
- elif sha3_256:
- type_sha3_256()
- hash_btn.flash()
- hash_pass.update(pass_entry.encode("UTF-8"))
- var.set("EQUIVALENT HASH: " + str(hash_pass.hexdigest()))
- entry_hash.config(textvariable=var)
- label_hash_name["text"] = ("CURRENT HASH ALGORITHM: ", hash_pass.name)
- label_hash_size["text"] = ("HASH SIZE(Bytes): ", hash_pass.digest_size)
- label_hash_internal_size["text"] = ("INTERNAL HASH BLOCK SIZE(BYTES): ", hash_pass.block_size)
- print(hashlib.algorithms_available)
- def how_to_use():
- tk.messagebox.showinfo("Usage", "Simply input a string of characters and choose the type of hash")
- menu_bar = tk.Menu(window)
- window.config(menu=menu_bar)
- sub_menu = tk.Menu(menu_bar, tearoff=0)
- menu_bar.add_cascade(label="About", command=about)
- menu_bar.add_cascade(label="Help", menu=sub_menu)
- sub_menu.add_command(label="How to use", command=how_to_use)
- sub_menu1 = tk.Menu(menu_bar, tearoff=0)
- menu_bar.add_cascade(label="Hash Type", menu=sub_menu1)
- md5 = sub_menu1.add_command(label="MD5", command=type_md5)
- sha256 = sub_menu1.add_command(label="SHA256", command=type_sha256)
- sha512 = sub_menu1.add_command(label="SHA512", command=type_sha512)
- sha3_384 = sub_menu1.add_command(label="SHA3_384", command=type_sha3_384)
- sha3_256 = sub_menu1.add_command(label="SHA3_256", command=type_sha3_256)
- canvas = tk.Canvas(window, height=HEIGHT, width=WIDTH)
- canvas.pack()
- # bg_image = tk.PhotoImage(file="background.png")
- # bg_label = tk.Label(window, image=bg_image)
- # bg_label.place(relwidth=1, relheight=1)
- top_frame = tk.Frame(window, bd=5, bg="#999999")
- top_frame.place(relheight=0.25, relwidth=1.0)
- input_label = tk.Label(top_frame, text="Input ----> ")
- input_label.place(x=5, relheight=0.25, relwidth=0.25)
- pass_entry = tk.Entry(top_frame, bg="#666666", show="*", fg="white")
- pass_entry.place(relx=0.27, relwidth=0.73, relheight=0.25)
- hash_btn = tk.Button(top_frame, text="HASHIFY!", bg="#336699", relief="ridge", activebackground="black",
- command=lambda: hash_it(pass_entry.get()))
- hash_btn.place(relx=0.40, y=60, relheight=0.25, relwidth=0.20)
- entry_hash = tk.Entry(window, relief="solid", state="readonly", fg="red", font="bold")
- entry_hash.place(rely=0.20, relheight=0.10, relwidth=1.0)
- btm_frame = tk.Frame(window, bg="#000000")
- btm_frame.place(rely=0.40, relheight=0.90, relwidth=1.0)
- label_hash_name = tk.Label(window, relief="solid")
- label_hash_name.place(relx=0.25, rely=0.40, relheight=0.10, relwidth=0.5)
- label_hash_internal_size = tk.Label(window, relief="solid")
- label_hash_internal_size.place(relx=0.25, rely=0.50, relheight=0.10, relwidth=0.5)
- label_hash_size = tk.Label(window, relief="solid")
- label_hash_size.place(relx=0.25, rely=0.60, relheight=0.10, relwidth=0.5)
- window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement