Lab 4: Databased Admin Tool Continued Python
Objective: In the previous lab, you developed an admin tool for username and password management. You accomplished the tasks with Dictionary or List. Here, use class to design your own data structure to accomplish a similar task.
The UD.txt datafile:
FIRST NAME, LAST NAME,USERNAME,PASSWORD
Sam, DDal,sdd233,Pad231
Dave, Dcon,dcf987, BHYW4fw
Dell, Grant,dgr803,Sb83d2d
Mike, Kress,mkr212,UNNHS322
Lisa,Kate,lki065,dgw6234
Paul,Edward,ped332,9891ds
Youyou,Tranten,ytr876,dsid21kk
Nomi,Mhanken,nmh223,3282jd3d2
Write a program that imports the database from UD.txt, your program can search for users’ password.
Give the following options:
A: Search by (firstname, lastname) (the first and last name is separated by “,”)
B: Search by username
C: Insert a user
E. Display all users
If the user is found, display the user’s password, and return the user to menu.
If user not found, display “Not found”, and return the user to menu
If the user is found, display the user’s password, and return the user to menu.
If user not found, display “Not found”, and return the user to menu.
Draw the UML diagram for the class and upload with your .py file. Follow the file submission rule.
## PYTHON CODE BEGINS ##
# For the regex used in re.split()
import re
# Class for an entry in the database
class UserData:
# Constructor
def __init__(self, firstName, lastName,
username, password):
self.__firstName =
firstName
self.__lastName =
lastName
self.__username =
username
self.__password =
password
# Accessors
def setFirstName(self, firstName):
self.__firstName =
firstName
def setLastName(self, lastName):
self.__lastName =
lastName
def setUsername(self, username):
self.__username =
username
def setPassword(self, password):
self.__password =
password
def getFirstName(self):
return
self.__firstName
def getLastName(self):
return
self.__lastName
def getUsername(self):
return
self.__username
def getPassword(self):
return
self.__password
# Function to load up the database form file
def importDatabase():
db = []
datafile = open("UD.txt", "r")
lines = datafile.readlines()
lines = lines[1:]
for line in lines:
line = re.split(', |,',
line)
firstName, lastName,
username, password = line
db.append(UserData(firstName, lastName, username, password))
return db
# Function to search the database by name
def searchByName(database):
firstName, lastName = input("Enter user’s name
in the form: Firstname Lastname: ").split()
for entry in database:
# print("comparing",
firstName, "with", entry.getFirstName(), "and", lastName, "with",
entry.getLastName())
if(entry.getFirstName()
== firstName and entry.getLastName() == lastName):
# print("FOUND MATCH!!!")
print(entry.getPassword())
return
print("Not found")
# Function to search the database by username
def searchByUsername(database):
username = input("Enter user’s username:
")
for entry in database:
if(entry.getUsername()
== username):
print(entry.getPassword())
return
print("Not found")
# Function to insert a new entry
def insertUser(database):
firstName, lastName, username, password =
input("Enter user info in the following format: First name, last
name, username, password: ").split(', ')
database.append(UserData(firstName, lastName,
username, password))
# Function to display all the entries in the database
def displayAllUsers(database):
for entry in database:
print("First Name :",
entry.getFirstName())
print("Last Name :",
entry.getLastName())
print("Username :",
entry.getUsername())
print("Password :",
entry.getPassword())
print("")
# Function to display the menu
def menu():
print('A: Search by (firstname, lastname) (the
first and last name is separated by “,”)')
print('B: Search by username')
print('C: Insert a user')
print('D. Display all users')
# Main program
def main():
database = importDatabase()
while True:
menu()
choice = input()
if choice in ['A',
'a']:
searchByName(database)
elif choice in ['B',
'b']:
searchByUsername(database)
elif choice in ['C',
'c']:
insertUser(database)
elif choice in ['D',
'd']:
displayAllUsers(database)
else:
break
if __name__ == "__main__":
main()
## PYTHON CODE ENDS ##
Lab 4: Databased Admin Tool Continued Python Objective: In the previous lab, you developed an admin tool for username an...
Lab 3: Databased Admin Tool Python Objective: Develop an admin tool for username and password management. You will need to use the best data structure to store the data you read from UD.txt for efficient processing. You can accomplish these tasks with Dictionary or List. The data file (UD.txt) : FIRST NAME, LAST NAME,USERNAME,PASSWORD Sam, DDal,sdd233,Pad231 Dave,Dcon,dcf987, BHYW4fw Dell,Grant,dgr803,Sb83d2d Mike,Kress,mkr212,UNNHS322 Lisa,Kate,lki065,dgw6234 Paul,Edward,ped332,9891ds Youyou,Tranten,ytr876,dsid21kk Nomi,Mhanken,nmh223,3282jd3d2 Write a program that imports the database from UD.txt Give the following options: A: Search by...
need help in Java Now we’ll continue our project by writing a Facebook class that contains an ArrayList of Facebook user objects. The Facebook class should have methods to list all of the users (i.e. print out their usernames), add a user,delete a user, and get the password hint for a user You will also need to create a driver program. The driver should create an instance of the Facebook class and display a menu containing five options: list users...
Lab Assignment – Database Implementation and Security In this lab you will create a Microsoft Access database of employee information and secure the table username and password security. Steps Enter data for five employee records. Each record should have fields: Employee ID (5 digits), First Name, Last Name, Home Address, Hire Date Create a query that displays Employee ID, First Name and Last Name. Create a form that requires entering username and password to access employee table. Error message should...
Inventory ManagementObjectives:Use inheritance to create base and child classesUtilize multiple classes in the same programPerform standard input validationImplement a solution that uses polymorphismProblem:A small electronics company has hired you to write an application to manage their inventory. The company requested a role-based access control (RBAC) to increase the security around using the new application. The company also requested that the application menu must be flexible enough to allow adding new menu items to the menu with minimal changes. This includes...
Problem:A small electronics company has hired you to write an application to manage their inventory. The company requested a role-based access control (RBAC) to increase the security around using the new application. The company also requested that the application menu must be flexible enough to allow adding new menu items to the menu with minimal changes. This includes re-ordering the menu items and making changes to the description of a menu item without having to change the code.Security:The company has...
In C , checks if the entered password for admin is correct by calling checkAdminPassword. Part of this function has been implemented, complete the statement in if(). Keep in mind that the entered password is plaintext whereas the password in struct user is in the hashsed form. The password for user admin is “s#1Pa5”. int checkAdminPassword(char* password, struct user* users, int count) { for (int i = 0; i < count; ++i) { if (strcmp((users + i)->username, "admin") == 0)...
Lab Assignment – Database Implementation and Security In this lab you will create a Microsoft Access database of employee information and secure the table username and password security. Steps Enter data for five employee records. Each record should have fields: Employee ID (5 digits), First Name, Last Name, Home Address, Hire Date Create a query that displays Employee ID, First Name and Last Name. Create a form that requires entering username and password to access employee table. Error message should...
Using Python INST-FS-IAD-PROD.INS LAB1 Lab: Create User Account 2. get-password() #promt the user and create password, check the password fits the requirement USE the EXACT file names! Create a user login system. Your code should do the following: 3, create-user_name() #use this function to create the user name 1.Create your user database called "UD.txt", this should be in CSV format 4, write-file() #user this function to save the user name and password into "UD.txt" Deliverables: Sample: the data you saved...
3. As a system admin, on your Ubuntu server, you are asked to complete these tasks: • Create these directories: documents, data, bin so that every user added will automatically have these directories in their home directory • Add a new user with username as jdoe and full name jane doe, and create the home directory for the user at the same time • Assign a password jdoe1234! to that user • Set the password to expire after 60 days...
Part 2: Processing Strings (Individual work) Processing user-entered data to follow a specific format is a common task. Often this involves using string functions to manipulate a set of input strings. Create a MATLAB script named namephone.m and place these lines of code at the beginning: name = input('Enter your first and last name: ','s'); phone = input('Enter your area code and phone number: ','s'); Tasks Here are useful string functions: length, strcat, strtrim, lower, upper, strcmp, findstr, strrep As you work...