Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Passwords ()bbb8452 75s6tt15 Dogmit3 58637iy4 Create a file containing the passw

ID: 3779447 • Letter: P

Question

Passwords

()bbb8452

75s6tt15

Dogmit3

58637iy4

Create a file containing the passwords above. Convert the passwords to SHA function 128 bits. Write a PYTHON code that displays a GUI that offers the user to enter a password for a constant username “shoeshoe.” Password must be 8 character long. Password entered should be converted to SHA 128 bit and be compared to the passwords above. If the password matches, the GUI should display “welcome” but if it a wrong password, it should display “wrong password, please try again” No minimum attempts.

Explanation / Answer

from tkinter import *
import hashlib

class Application(Frame):
def __init__(self,master):
super(Application, self).__init__(master)#Set __init__ to the master class
self.grid()
self.create_main()#Creates function

def create_main(self):
print("testing")
self.title = Label(self, text=" Stuck In The Circle ")#TITLE
self.title.grid(row=0, column=2)

self.user_entry_label = Label(self, text="Username: ")#USERNAME LABEL
self.user_entry_label.grid(row=1, column=1)

self.user_entry = Entry(self) #USERNAME ENTRY BOX
self.user_entry.grid(row=1, column=2)

self.pass_entry_label = Label(self, text="Password: ")#PASSWORD LABEL
self.pass_entry_label.grid(row=2, column=1)

self.pass_entry = Entry(self) #PASSWORD ENTRY BOX
self.pass_entry.grid(row=2, column=2)

self.sign_in_butt = Button(self, text="Sign In",command = self.logging_in)#SIGN IN BUTTON
self.sign_in_butt.grid(row=5, column=2)

def logging_in(self):
       print("hi")
       user_get = self.user_entry.get()#Retrieve Username
       pass_get = self.pass_entry.get()#Retrieve Password
       sha_1 = hashlib.sha1()
       sha_1.update("bbb8452")
       sha_2 = hashlib.sha1()
       sha_2.update("75s6tt15")
       sha_3 = hashlib.sha1()
       sha_3.update("Dogmit3")
       sha_4 = hashlib.sha1()
       sha_4.update("58637iy4")
      
       userpwd = hashlib.sha1()
       userpwd.update("58637iy4")
      
       outputhash.write(sha_1.hexdigest())
       if userpwd.hexdigest() == sha_1.hexdigest() || userpwd.hexdigest() == sha_2.hexdigest() || userpwd.hexdigest() == sha_3.hexdigest() || userpwd.hexdigest() == sha_4.hexdigest():
           print("Welcome!")

#Main
root = Tk()
root.title("Stuck in the Circle")
root.geometry("400x100")

app = Application(root)#The frame is inside the widgit
root.mainloop()#Keeps the window open/running