Guest User

Untitled

a guest
Sep 12th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. Check if password and username input match in Python?
  2. from tkinter import *
  3. from getpass import getpass
  4.  
  5. def callback():
  6. print(E1)()
  7.  
  8. top = Tk()
  9. L1 = Label(top, text="User Name")
  10. L1.grid(row=0, column=0)
  11. E1 = Entry(top, bd = 5)
  12. E1.grid(row=0, column=1)
  13.  
  14. L1 = Label(top, text="Password")
  15. L1.grid(row=1, column=0)
  16. E1 = Entry(top, bd = 5,show="•")
  17. E1.grid(row=1, column=1)
  18.  
  19. MyButton1 = Button(top, text="Submit", width=10, command=callback)
  20. MyButton1.grid(row=3, column=1)
  21.  
  22. top.mainloop()
  23.  
  24. import getpass, hashlib
  25.  
  26. USER = 'ali_baba'
  27. # hashlib.md5('open sesame').hexdigest()
  28. PASSWORD_HASH = '54ef36ec71201fdf9d1423fd26f97f6b'
  29.  
  30. user = raw_input("Who are you? ")
  31. password = getpass.getpass("What's the password? ")
  32. password_hash = hashlib.md5(password).hexdigest()
  33.  
  34. if (user == USER) and (password_hash == PASSWORD_HASH):
  35. print "user authenticated"
  36. else:
  37. print "user authentication failed"
  38.  
  39. # hashlib.md5('ali_baba:open sesame').hexdigest()
  40. AUTH_HASH = '0fce635beba659c6341d76da4f97212f'
  41. user = raw_input("Who are you? ")
  42. password = getpass.getpass("What's the password? ")
  43. auth_hash = hashlib.md5('%s:%s' % (user, password)).hexdigest()
  44. if auth_hash == AUTH_HASH:
  45. print "user authenticated"
  46. else:
  47. print "user authentication failed"
Add Comment
Please, Sign In to add comment