Info
Warning
Danger
/ Homework Answers / Computer Science / Question Need help with the class functions and the driver file.

Question

Question

Need help with the class functions and the driver file. Classeshave been very hard for me to understand and any help would beappreciated. Thanks!

Problem:

Write a C++ program that will manage passwords.

Your program will contain:

A Class, PasswordManager, that will manage a singlepassword.

A main function, that will allow the user to test thePasswordManager class.

Your program should consist of the following files:PasswordManager.h

PasswordManager.cpp

PasswordDriver.cpp (containing the main function)

You should also have a makefile that can beused to build the executable program. Note: apassword does not contain any whitespace. When a password isbeing

entered by the user, assume a whitespace character indicates theend of the password.

PasswordManager Class:

The PasswordManager class should have just one member variable,which will store the

encrypted password (a string). Do not store thepassword unencrypted!

The PasswordManager class should have the following two internalmember functions

(not accessible outside of the class):

encrypt: this takes a password (a string) andreturns the encrypted form of the password. Note: there is nodecrypt function (there is no need to decrypt passwords). We willuse the following VERY simple encryption algorithm (a CaesarCipher):

For every character in the input string, add 10 to the asciivalue of the character. The encrypted character’s ascii value muststay in the range of printable, non- whitespace characters: 33 to126. This can be enforced using this formula: ascii value ofencrypted char =

     ((ascii value of ch - 33) + 10) % 94 + 33

1

Store all the resulting chars in a string to be returned as theresult of the function (hint: use the string.append function, or +or +=).

verifyPassword: this takes a string (apassword) and returns true if it meets the following criteria:

it is at least 8 characters long

it contains at least three out of the following four types ofcharacters:

- Uppercase letters

- Lowercase letters - Numbers

- Symbols

Otherwise it returns false.

The PasswordManager should have the following member functions thatare accessible

outside of the class:

setEncryptedPassword: (a setter function) takesa string (an encrypted password) and stores it in the membervariable.

getEncryptedPassword: (a getter function)returns the value of the encrypted password stored in the membervariable.

setNewPassword: takes a string (a proposedpassword). If it meets the criteria in verifyPassword, it encryptsthe password and stores it in the member variable and returns true.Otherwise returns false.

validatePassword: takes a string (a password)and returns true if, once encrypted, it matches the encryptedstring stored in the the member variable. Else returns false.

Input/Output:

The main function should create and use one instance of thePasswordManager class. It is called “the password manager”below.

Your main function will use a file “password.txt” to store theencrypted password in between executions of the program. However,the file may not yet exist the first time the program is executed.So when your main function starts, it should first try to input anencrypted password from the file “password.txt”. If the file existsand contains a string, the program should set the encryptedpassword in the password manager. Otherwise it should set thepassword in the password manager to “abc123@@@”.

Your program will use the following menu to prompt the user totest the implementation:

2

     Password Utilities:     A. Change Password     B. Validate Password     C. Quit

     Enter your choice:

The menu should be processed in a loop, so the user may continuetesting the password operations.

The Change Password option should ask the user to enter a newpassword, and explain the criteria for a valid password. The mainfunction should call the password manager to verify and change thepassword. It should output a message indicating whether or not thepassword was changed. If it was not changed, it should NOT repeatand ask the user to try again.

The Validate Password option should ask the user to input thepassword. Then the main function should call the password managerto validate the password, and then the main function should outputwhether or not the password was valid (matching the one stored bythe password manager) or not. If it was not valid, it should NOTrepeat and ask the user to try again.

When the user selects C to quit, the program should save theencrypted password in the file “password.txt” (overwriting anythingthat was previously in the file).

NOTES:

Do NOT change the names of the functions! Use the exact samefunction names, and do not change the case (uppercase/lowercase).DO NOT change the menu choice letters.

Create and use a makefile to compile theexecutable program. Modify the one from the lecture. I recommendcalling the executable file “password”.

Put the Class declaration in the header file, the implementationof the class member functions in PasswordManager.cpp and the mainfunction in PasswordDriver.cpp. Put a header comment at the top ofeach file.

ALL of the input and output must be done by the driver.The password manager class should not do ANYinput/output, not to the screen OR the file!

constructor functions are NOT required.

Your program must compile and run, otherwiseyou will receive a score of 0.

3

• Your program must pass Test Case 0 or youwill receive a score of 30 or less with no credit for the othergrading categories (correctness/constraints/style). The inputvalues and expected output are in a file calledTC0.txt on the class website. This test casechanges the password, then attempts to validate the new password(the password does not need to be saved to a fileto pass TC0). Your program must contain a PasswordManager class topass TC0.

 

Solution
5 (1 Ratings )

Solved
Computer Science 1 Week Ago 9 Views
This Question has Been Answered!
Premium Content -

Unlimited Access

Explore More than 2 Million+
  • Textbook Solutions
  • Flashcards
  • Homework Answers
  • Documents
Signup for Better Grades!

Ask an Expert

Our Experts can answer your tough homework and study questions
150466 Computer Science Questions Answered!
Post a Question

Welcome Back!

ScholarOn has more then 20 Million answers, flashcards & more being added everyday!

or
Forgot?
Login
Don't have an account? Signup

Join ScholarOn

ScholarOn has more then 20 Million answers, flashcards & more being added everyday!

or
Signup
By registering, I agree to the Terms and Privacy Policies
Already have an account? Log in

Verify Your Email

Check your inbox & click on the link to activate your account.

Resend Email
Verification Mail Send Successfully. Please Check Your Email.

Forgot Password

Please enter your registered email to recieve the password reset link.

Send reset link
Already have an account? Log in
Did you know?

ScholarOn has more than 2 Million+ answers, textbook solutions & flashcards. Explore Now!

Let us boost your grade together!