Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def click(button):
- if button == "Cancel":
- login.stop()
- if button == "Register":
- login.stop()
- register.go()
- else:
- usr = login.getEntry("Username")
- pwd = login.getEntry("Password") #collects entry of password & username
- ###MD5 HASHING###
- pwdencypt = hashlib.md5(pwd.encode('utf-8')) #makes the encypted password using md5 hashing
- print(pwdencypt.hexdigest())
- pwd2 = pwdencypt
- conn = sqlite3.connect("uHubDatabase.db")
- cursor = conn.cursor() #connects to database
- ###USERNAME SECTION###
- find_user=("SELECT Username FROM UserTable WHERE Username = ?") #sets the finding of the username from the database as a varaible
- cursor.execute(find_user,[(usr)])
- founduser = str(cursor.fetchall())
- print(founduser)
- removechars = "'(),[]" #Avoids the error of special characters caused by the database outputting strings (Text)
- for char in removechars:
- founduser = founduser.replace(char,'')
- ###PASSWORD SECTION###
- find_pass=("SELECT Password FROM UserTable WHERE Password = ?") #sets the finding of the password from the database as a varaible
- cursor.execute(find_pass,[(pwd2)])
- foundpass = str(cursor.fetchall())
- print(foundpass)
- removechars = "'(),[]" #Avoids the error of special characters caused by the database outputting strings (Text)
- for char in removechars:
- foundpass = foundpass.replace(char,'')
- ###DATA VARIABLE CHECKS###
- print("This is from Database(Username)",founduser)
- print("This is whats inputed",usr)
- print("This is from Database(Password)",foundpass)
- print("This is whats inputed",pwd)
- print("This is pwd but encypted",pwdencypt.hexdigest())
- if founduser == usr and foundpass == pwdencypt: # If correct
- print("SUCESS")
- login.stop()
- home.go()
- else: #if incorrect
- print("FAIL")
- login.retryBox("INCORRECT LOGIN", "The Username or Password entered are incorrect. Please try again.")
- print("User:", usr, "Pass:", pwd)
- conn.close() #closes connection
Add Comment
Please, Sign In to add comment