Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Check if password and username input match in Python?
- from tkinter import *
- from getpass import getpass
- def callback():
- print(E1)()
- top = Tk()
- L1 = Label(top, text="User Name")
- L1.grid(row=0, column=0)
- E1 = Entry(top, bd = 5)
- E1.grid(row=0, column=1)
- L1 = Label(top, text="Password")
- L1.grid(row=1, column=0)
- E1 = Entry(top, bd = 5,show="•")
- E1.grid(row=1, column=1)
- MyButton1 = Button(top, text="Submit", width=10, command=callback)
- MyButton1.grid(row=3, column=1)
- top.mainloop()
- import getpass, hashlib
- USER = 'ali_baba'
- # hashlib.md5('open sesame').hexdigest()
- PASSWORD_HASH = '54ef36ec71201fdf9d1423fd26f97f6b'
- user = raw_input("Who are you? ")
- password = getpass.getpass("What's the password? ")
- password_hash = hashlib.md5(password).hexdigest()
- if (user == USER) and (password_hash == PASSWORD_HASH):
- print "user authenticated"
- else:
- print "user authentication failed"
- # hashlib.md5('ali_baba:open sesame').hexdigest()
- AUTH_HASH = '0fce635beba659c6341d76da4f97212f'
- user = raw_input("Who are you? ")
- password = getpass.getpass("What's the password? ")
- auth_hash = hashlib.md5('%s:%s' % (user, password)).hexdigest()
- if auth_hash == AUTH_HASH:
- print "user authenticated"
- else:
- print "user authentication failed"
Add Comment
Please, Sign In to add comment