Question
I need help with this question. We are going to design and build an authentication program that lets users create new accounts and login to
I need help with this question.
We are going to design and build an authentication program that lets users create new accounts and login to existing accounts. When launched, the program prompts a menu.
I recommend creating a void function called printMenu() that prints the menu and primes the program for the user to enter an option. Recall that \t prints a tab and prints a carriage return to help format our output.
Use a switch statement to handle the menu option. If the user enters option 1, then a login() function is invoked, which authenticates a user. If option 2 is entered, then a createAccount() function is invoked, which creates a new user account. If option 3 is entered, then the program terminates. Include a default case to handle invalid entries.
You should have a do-while loop. Inside the loop, the printMenu() function is invoked and the users option is obtained. Following is the switch statement. The termination condition for the do-while loop should be while the users input is not equal to 3. This design lets the user create numerous accounts and login without having to re-execute the program.
When creating a new account, the program prompts the user for a first name and a last name. It then creates a username for the user, which is the first four characters of the last name and the first character of the first name. For example, if I enter Adam Duby as my name, then the program will generate dubya as my username. The username must be in all lowercase. Therefore, the program should include a routine that converts the username to all lowercase. The program then prompts for a password. The password must be at least 10 characters long and it cannot contain any whitespace. If the users password does not meet the length requirement, then the program displays a message and asks the user to try again.
There needs to be a database to store user credentials. The program reads and writes a text file, called creds.txt, which stores usernames and passwords. Use the fstream::app modifer when opening the output file stream to make sure that new accounts are appended to the creds database and do not overwrite exisiting account information.
The creds.txt database should store account information in the format username:password. The username and password are stored on the same line, seperated by a colon. Each username and password combination should be on its own line in the database.
It is not secure to store passwords in plain text, so they should be stored in an encrypted form. Store the passwords in a ROT-13 encrypted format. Here is an example of a creds.txt file:
The passwords are stored in encrypted form. Upons successful creation of a new account, the program primts a message and notifies the user of their username and new email address. The email address is of the form username@norwich.edu.
When logging in, the program prompts for the username and password then checks the creds.txt database to see if there is a match. If a match is found a welcome message is generated. If no match is found, a login failure message is generated.
Some things to keep in mind while designing your program:
What happens if a user has a last name less than four characters in length? Your software should be able to handle this. One way is to add letters to the end of the last name.
Program should be able to handle multiple user accounts. Users should only have to establish their account once and can login the future, even after the program terminates.
Be sure to practice secure coding.
Do not open file streams until needed and close them as soon as you are done with them.
Include input validation as appropriate.
Include error handling. For example, how does the software react if the creds.txt database file gets deleted or moved? It should fail gracefully and include an error message to the console instead of crashing or freezing. if (!inFile) is a good way to do this type of checking. You can opt to do exception handling, or you can handle these types of errors as you see fit. Here is a function I use to check my input file streams to make sure that it opened successfully before I try to read from the file.
Here are some screenshots of how the program should generally look in action. Your solutions may vary:
Your overall design and architecture will be assessed during grading. Be sure to use functions as appropriate. You are free to design your functions as you deem appropriate, but keep in mind modularity, code re-use, and designing for expansion. I am including the function prototypes I used to give you a general idea of how you can approach a function decomposition for this problem.
Please choose one of the following options: Enter', 1 ', to login to an existing account Enter '2', to create a new account Opt ion: ofstream outFile; string outFileName = "creds.txt"; outFile.open(outFileName.c_str(), fstream::app); creds.txt - Notepad File Edit Format View Help hamnj : >?QMdR&r dubya: \{|!8vpup(o!?>- crisk: (*Gnls22Kla ' f4 ! string encrypt (string); void printmenu (); string createUsername (string, string); void login(); bool opencreds (ifstreams); bool checkCreds (string, string); void createAccount (); string generatePassword () ; bool processNewAccount (string, string)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started