Question: Introduction In this mini project, you will process some input to confirm a user account. You will not actually create any accounts, just go through
Introduction
In this mini project, you will process some input to confirm a user account. You will not actually create any accounts, just go through the process of validating some input and witting information to a file.
You will be storing information to a text file. The file will contain user names and passwords. The file contains lines of text. Each line is in the form username::password - where username is a unique username and password is an obfuscated version of the user's password.
We don't want the passwords as easily read text, so we need to "encrypt" them before storing or checking the file. The password is stored as follows:
- A user has a password that is at least 7 characters and does not contain the following characters: ! @ $ : ?
- Step 1 takes the first and last character in the password and swaps them.
- Step 2 makes the following substitutions:
- lowercase i is replaced with !
- lowercase a is replaced with @
- uppercase S is replaced with $
- uppercase J is replaced with ?
For example the password: IsSnappleJuice would be stored es$n@pple?uIcI
A user has a first name and a second name. The username will be the first letter of the user's first name concatenated with their entire second name followed by a 4 digit random number. Example user name: Max ortiz becomes mortiz
User log in is as follows:
- You will prompt the user their username.
- If the file contains an entry with that username, then prompt for a password and prompt again.
- Compare the two passwords the user entered to be sure they are the same. I
- f the do not match, prompt the user to enter passwords until 2 match.
- If the user does not exists the will be given the choice to be added to the system.
- Prompt the user for the first and last name
- Generate a username as above
- check the file to see if it is a unique username
- if it is not unique user, generate new 4 digit number and replace the old
- repeat until you have a good name
- prompt the user for their pass 2 times and confirm it just as above
- Add the user and pass to the file
See the requirements below for more
Instructions
Write a program that meets the following requirements:
- If the file does not exist, create a file called users.txt
- if the file does not exist, create a file called log.txt
- Ask a user if they have a username.
- If they are an existing user
- prompt them for their username
- check if a line starts with that user name
- if a line exists, retrieve the username and password.
- prompt the user for their password
- "encrypt" the given password as instructed above
- check if the stored password matches the newly encrypted one.
- append the following to the log file
- [USERNAME] :: [DATETIME] :: [STATUS]
- replace [USERNAME] with the current user's username
- replace [DATETIME] with the current system time
- you will have to research how to get the date and time (hint: import something)
- *any date/time format is fine
- replace status with OK if the passwords match
- replace status with BAD PASS if the passwords do not match
- if the passwords do not match, allow the user to try again but after 3 bad attempts the user has failed
- if this occurs append a new line that has a FAILED status.
- if a line exists, retrieve the username and password.
- if they are not an existing user
- Prompt user for first name
- Prompt user for second name
- Search the user file for a line that starts with the username for a user with the given first and second name
- if a user exists, generate a 2 digit random positive number, append it to the username. Check the file to make sure this is a unique name. Repeat this until a unique name is created.
- if they do not exisit
- Create a username as stated above.
- Prompt the user for their new password
- The password should be at least 7 characters long.The password cannot contain the special characters stated above.
- If the password is less than 7 characters or contains the special characters - repeat until a valid password is entered.
- If the password is valid
- Prompt the user to re-enter the password
- If the two passwords match
- Append the file to include the new username and password as stated above.
- If they are an existing user
- You need to have fa unction to "encrypt" the password.
- You need to have a function that takes the line from the file and returns the username part
- You need to have a function that takes the line from the file and returns the password part
- You need at least two loops
- You need at least two if statements
- Best to use lots of functions.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
