Hello I need help with the below problem, as my code isn't working properly. I have written my code in Python, but need

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Hello I need help with the below problem, as my code isn't working properly. I have written my code in Python, but need

Post by answerhappygod »

Hello I need help with the below problem, as my code isn't working properly. I have written my code in Python, but need to meet the requirements below. The passwords need to come from a text file and compared to the text files previously saved passwords. Thank you!
from tkinter import *
f = open("./oldpassword.txt", "r")oldPasswordList = [x.replace("\n", "") for x in f.readlines()]
bullet = "\u2022"root = Tk()root.title("Password Checker GUI")
root.geometry("600x400")
def CheckPassword(): entered_password1 = password1_entry.get() entered_password2 = password2_entry.get()
upper, isdigit, special = 0, 0, 0 for i in range(len(entered_password1)): if entered_password1.isupper(): upper += 1 elif entered_password1.isdigit(): isdigit += 1 elif entered_password1.isupper() == False and entered_password1.islower() == False and entered_password1[ i].isdigit() == False: special += 1
if entered_password1 != entered_password2: result_entry.insert(0, "Passwords dont match") elif userID_entry == False: result_entry.insert(0, "Enter Username") elif len(entered_password1) < 12: result_entry.insert(0, "Your password should be 12 character long.") elif entered_password1 in oldPasswordList: result_entry.insert(0, "You cannot use your old password.") elif (any(x.islower() for x in entered_password1)) == False: result_entry.insert(0, "Password should contain atleast lowercase characters.") elif upper < 2: result_entry.insert(0, "Password should contain atleast 2 uppercase characters.") elif isdigit < 2: result_entry.insert(0, "Password should contain atleast 2 digits.") elif special < 1: result_entry.insert(0, "Need atleast 1 special character.") else: result_entry.insert(0, "Password Accepted")
userID_label = Label(root, text = 'Enter your User ID', font = ('calibre', 10, 'bold'))userID_entry = Entry(root, width = 50, font = ('calibre', 10, 'normal'), justify = 'center')
password1_label = Label(root, text='Enter your new password', font=('calibre', 10, 'bold'))password1_entry = Entry(root, show=bullet, width=50, font=('calibre', 10, 'normal'), justify='center')
password2_label = Label(root, text = 'Confirm new password', font = ('calibre', 10, 'bold'))password2_entry = Entry(root, show = bullet, width = 50, font = ('calibre', 10, 'normal'), justify='center')
result_label = Label(root, text = 'Result', font = ('calibre', 10, 'bold'))result_entry = Entry(root, width = 50, font = ('calibre', 10, 'normal'), justify = 'center')
userID_label.grid(row = 0, column = 1, padx = 10, pady = 10)userID_entry.grid(row = 0, column = 2, padx = 10, pady = 10)
password1_label.grid(row = 3, column = 1, padx = 10, pady = 10)password1_entry.grid(row = 3, column = 2, padx = 10, pady = 10)
password2_label.grid(row = 4, column = 1, padx = 10, pady = 10)password2_entry.grid(row = 4, column = 2, padx = 10, pady = 10)
result_label.grid(row = 5, column = 1, padx = 10, pady = 10)result_entry.grid(row = 5, column = 2, padx = 10, pady = 10)
myButton = Button(root, text = "Check Password Validity", command = CheckPassword)myButton.grid(row = 6, column = 2)root.mainloop()
Below are the requirements:
The program can be written in Python Database should have minimum two tables – fn_user table and a fn_password_history table. Foreach user in the user table there should be Five old passwords. The keys and relevant columnsneeded to be added to these tables (where fn is your first name).
 Create a Change Password GUI for checking the validity of a password.o There should be an entry box for user id. User Id should be your email. Check to makesure that this is a valid Email.o The user ID you entered should already exist in the database in user table and if not itshould say User Id does not exist.o There should be an Old Password entry box where you enter the current password andthis should match the current password in the user table.o When you enter the old password, password should not be visible (.....).o There should be a New password entry box where you enter the new password.o When you enter the new password, password should not be visible (.....).o There should be a Confirm New Password entry box where you should re-enter thepassword. Here also the password should not be visible.o There should be a BUTTON called “Change Password”.o GUI is not shown. You can have variations of the GUI in assignment 4 as long as allfunctionalities are met.
 The new password string entered in the new password box should be the same as the passwordstring entered in the confirm new password box
 The password should not be one of the last five passwords from the fn_password_history tablefor this user id including the current (or old) password.
 When the button is clicked the password validity is checked based on the followingconditions:
 The current password and the new password should not be the same. The password string entered in the New password box should be the sameas the password string entered in the confirm New password box The password should be at least 12 characters strong. The password should contain EXACTLY TWO upper case letters. The password should have EXACTLY TWO digits. The password should contain EXACTLY ONE special character like $ or !or %. The password should not contain any spaces. The password should contain all remaining lower case letters. The GUI should ask for a new password and then verifies that it meets the stated criteria. If itdoes it should return message “Password Changed” in the result box. If not it should return amessage as to what is wrong with the password and why it is not accepted. Only one reasonneeds to be displayed based on the order of errors given above.
 If password is accepted theo new password should be updated in the user table as the current passwordo new password should be updated in the password history table and replaces the fiftholdest password in the password history table with today’s date.
 All passwords in the database should be encrypted. You can use an existing algorithm to do this.You don’t have to write your own algorithm for this.
 Now describe a SQL injection case that can happen in your code. Attach a document showingwhat the threat is and specify how you have handled in the code. In the document identify thefile(s) where you have put the code to prevent SQL injection.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply