Guest User

Untitled

a guest
Jan 6th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. def click(button):
  2. if button == "Cancel":
  3. login.stop()
  4.  
  5. if button == "Register":
  6. login.stop()
  7. register.go()
  8.  
  9.  
  10.  
  11. else:
  12. usr = login.getEntry("Username")
  13. pwd = login.getEntry("Password") #collects entry of password & username
  14.  
  15. ###MD5 HASHING###
  16. pwdencypt = hashlib.md5(pwd.encode('utf-8')) #makes the encypted password using md5 hashing
  17. print(pwdencypt.hexdigest())
  18. pwd2 = pwdencypt
  19.  
  20. conn = sqlite3.connect("uHubDatabase.db")
  21. cursor = conn.cursor() #connects to database
  22.  
  23. ###USERNAME SECTION###
  24. find_user=("SELECT Username FROM UserTable WHERE Username = ?") #sets the finding of the username from the database as a varaible
  25. cursor.execute(find_user,[(usr)])
  26.  
  27.  
  28. founduser = str(cursor.fetchall())
  29. print(founduser)
  30. removechars = "'(),[]" #Avoids the error of special characters caused by the database outputting strings (Text)
  31. for char in removechars:
  32. founduser = founduser.replace(char,'')
  33.  
  34. ###PASSWORD SECTION###
  35. find_pass=("SELECT Password FROM UserTable WHERE Password = ?") #sets the finding of the password from the database as a varaible
  36. cursor.execute(find_pass,[(pwd2)])
  37.  
  38. foundpass = str(cursor.fetchall())
  39. print(foundpass)
  40. removechars = "'(),[]" #Avoids the error of special characters caused by the database outputting strings (Text)
  41. for char in removechars:
  42. foundpass = foundpass.replace(char,'')
  43.  
  44. ###DATA VARIABLE CHECKS###
  45. print("This is from Database(Username)",founduser)
  46. print("This is whats inputed",usr)
  47. print("This is from Database(Password)",foundpass)
  48. print("This is whats inputed",pwd)
  49. print("This is pwd but encypted",pwdencypt.hexdigest())
  50.  
  51. if founduser == usr and foundpass == pwdencypt: # If correct
  52. print("SUCESS")
  53. login.stop()
  54. home.go()
  55.  
  56. else: #if incorrect
  57. print("FAIL")
  58. login.retryBox("INCORRECT LOGIN", "The Username or Password entered are incorrect. Please try again.")
  59. print("User:", usr, "Pass:", pwd)
  60.  
  61. conn.close() #closes connection
Add Comment
Please, Sign In to add comment