Skip to content

Instantly share code, notes, and snippets.

@BaileyJM02
Last active March 14, 2019 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BaileyJM02/bd9c85a0e221166c448cebd2dcb83af6 to your computer and use it in GitHub Desktop.
Save BaileyJM02/bd9c85a0e221166c448cebd2dcb83af6 to your computer and use it in GitHub Desktop.
import hashlib
import webbrowser
import tkinter as tkinter
from tkinter import messagebox
import time
from random import *
from tkinter import ttk
hash30 = """
_ _ _ _ _ _ _ _ _ _
/ /\ / /\ / /\ / /\ / /\ / /\ /\ \ /\ \ /\ \ / /\
/ / / / / // / \ / / \ / / / / / // \ \ / \ \ / \ \ / / \
/ /_/ / / // / /\ \ / / /\ \__ / /_/ / / // /\ \ \ / /\ \ \ / /\ \ \ / / /\ \
/ /\ \__/ / // / /\ \ \ / / /\ \___\ / /\ \__/ / // / /\ \_\ / / /\ \_\ / / /\ \ \ / / /\ \ \
/ /\ \___\/ // / / \ \ \ \ \ \ \/___// /\ \___\/ // /_/_ \/_/ / / /_/ / / \/_//_\ \ \ /_/ / \ \ \
/ / /\/___/ // / /___/ /\ \ \ \ \ / / /\/___/ // /____/\ / / /__\/ / __\___ \ \ \ \ \ \ \ \
/ / / / / // / /_____/ /\ \ _ \ \ \ / / / / / // /\____\/ / / /_____/ / /\ \ \ \ \ \ \ \ \ \
/ / / / / // /_________/\ \ \ /_/\__/ / / / / / / / // / /______ / / /\ \ \ / /_/____\ \ \ _ \ \ \___\ \ \
/ / / / / // / /_ __\ \_\\\ \/___/ / / / / / / // / /_______\/ / / \ \ \ /__________\ \ \/\_\\\ \/____\ \ \
\/_/ \/_/ \_\___\ /____/_/ \_____\/ \/_/ \/_/ \/__________/\/_/ \_\/ \_____________\/\/_/ \_________\/
Hasher 3.0
"""
info = {"Version":"3.0a", "Author":"Bailey Matthews"}
text = """
After clicking "Continue" please type in a
phrase you would like to be hashed. Hasher
3.0 uses sha512 and a salt to hash your phrase.
The salt is made up of one string that
contains a human written text along with a
random integer between 0 and 1.
If you find any problems please report
them below on Github.
(https://github.com/BaileyJM02)
"""
def link(event):
webbrowser.open_new(event.widget.cget("text"))
class welcomeWindow:
print("Opened: Welcome")
def __init__(self, appWelcome):
#Add some text:
self.title = tkinter.Label(appWelcome, text=hash30, font=('monospace', 10))
self.title.grid(row=1, column=0, columnspan=6, padx=7.5, pady=7.5)
self.sub = tkinter.Label(appWelcome, text="Made by {author}\nCurrent version: {version}".format(author=info['Author'], version=info['Version']), font=('Helvetica', 10))
self.sub.grid(row=2, column=0, columnspan=6, padx=7.5, pady=7.5)
self.text = tkinter.Label(appWelcome, text=text, font=('Helvetica', 10))
self.text.grid(row=3, column=0, columnspan=6, padx=7.5, pady=7.5)
self.button = tkinter.Button(appWelcome, text="Licence", command=self.licence)
self.button.grid(row=4, column=3, padx=7.5, pady=7.5)
self.button = tkinter.Button(appWelcome, text="Continue", command=self.buttonContinue)
self.button.grid(row=4, column=4, padx=7.5, pady=7.5)
def licence(self):
webbrowser.open_new(r"https://creativecommons.org/licenses/by-sa/4.0/") #licence
def buttonContinue(self):
welcome.destroy()
HasherCaller()
class HasherAppWindow:
print("Opened: HasherApp")
def __init__(self, appHasherApp):
#Add some text:
self.title = tkinter.Label(appHasherApp, text=hash30, font=('monospace', 10))
self.title.grid(row=1, column=0, columnspan=6, padx=7.5, pady=7.5)
self.hashTitle = tkinter.Label(appHasherApp, text="String to hash:", font=('Helvetica', 10), width=50)
self.hashTitle.grid(row=2, column=0, padx=7.5, pady=0)
self.hashKey = tkinter.Entry(appHasherApp, width=50)
self.hashKey.grid(row=2, column=2, padx=7.5, pady=10)
self.hashKey.focus_set()
self.buttonHash = tkinter.Button(appHasherApp, text="Hash It", command=self.hash, width=10)
self.buttonHash.grid(row=6, column=4, columnspan=2, padx=7.5, pady=7.5)
def hash(self):
self.separator = ttk.Separator(orient=tkinter.HORIZONTAL)
self.separator.grid(row=3, column=0, columnspan=6, ipadx=200, pady=7.5)
self.hashfieldTitle = tkinter.Label(text="Hash (using sha512):", font=('Helvetica', 10), width=50)
self.hashfieldTitle.grid(row=4, column=0, padx=7.5, pady=0)
self.hashfield = tkinter.Text(height=4, width=50)
self.hashfield.insert(tkinter.END, "Please enter your phrase above.")
self.hashfield.config(state=tkinter.DISABLED)
self.hashfield.grid(row=4, column=2, columnspan=2, padx=7.5, pady=5)
self.saltfieldTitle = tkinter.Label(text="Salt (using Random integer):", font=('Helvetica', 10), width=50)
self.saltfieldTitle.grid(row=5, column=0, padx=7.5, pady=0)
self.saltfield = tkinter.Text(height=2, width=50)
self.saltfield.insert(tkinter.END, "Please enter your phrase above.")
self.saltfield.config(state=tkinter.DISABLED)
self.saltfield.grid(row=5, column=2, columnspan=2, padx=7.5, pady=0)
key_string = str(self.hashKey.get()).encode('utf-8')
salt = "1Ha7+eHash3.0+pyth0n" + str(random())
saltutf_8 = salt.encode('utf-8')
crypto = hashlib.sha512(saltutf_8 + key_string).hexdigest()
self.hashfield.config(state=tkinter.NORMAL)
self.hashfield.delete(1.0, tkinter.END)
self.hashfield.insert(tkinter.END, crypto)
self.hashfield.config(state=tkinter.DISABLED)
self.saltfield.config(state=tkinter.NORMAL)
self.saltfield.delete(1.0, tkinter.END)
self.saltfield.insert(tkinter.END, salt)
self.saltfield.config(state=tkinter.DISABLED)
hashFile = open("hash.log","w")
hashFile.write(crypto)
hashFile.close()
self.buttonHash['text'] = "Hash Again?"
def HasherCaller():
global HasherApp
#Create the main root window, instantiate the object, and run the main loop!
HasherApp = tkinter.Tk()
HasherApp.title("Hasher v" + info["Version"]) # Sets title
HasherApp.columnconfigure(0, weight=100)
HasherApp.columnconfigure(1, weight=100)
app_HasherApp = HasherAppWindow(HasherApp)
## First window to open
welcome = tkinter.Tk()
welcome.title("Hasher v" + info["Version"]) # Sets title
try: welcome.wm_iconbitmap('alien.ico') #Icon may not be downloaded
except: None
welcome.columnconfigure(0, weight=100)
welcome.columnconfigure(1, weight=100)
app_welcome = welcomeWindow(welcome)
tkinter.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment