Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with the class functions and the driver file. Classes have been very h

ID: 3680629 • Letter: N

Question

Need help with the class functions and the driver file. Classes have been very hard for me to understand and any help would be appreciated. Thanks!

Problem:

Write a C++ program that will manage passwords.

Your program will contain:

A Class, PasswordManager, that will manage a single password.

A main function, that will allow the user to test the PasswordManager 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 be used to build the executable program. Note: a password does not contain any whitespace. When a password is being

entered by the user, assume a whitespace character indicates the end 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 the password unencrypted!
The PasswordManager class should have the following two internal member functions

(not accessible outside of the class):

encrypt: this takes a password (a string) and returns the encrypted form of the password. Note: there is no decrypt function (there is no need to decrypt passwords). We will use the following VERY simple encryption algorithm (a Caesar Cipher):

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

1

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

verifyPassword: this takes a string (a password) 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 of characters:

- Uppercase letters

- Lowercase letters - Numbers
- Symbols

Otherwise it returns false.
The PasswordManager should have the following member functions that are accessible

outside of the class:

setEncryptedPassword: (a setter function) takes a string (an encrypted password) and stores it in the member variable.

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

setNewPassword: takes a string (a proposed password). If it meets the criteria in verifyPassword, it encrypts the 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 encrypted string stored in the the member variable. Else returns false.

Input/Output:

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

Your main function will use a file “password.txt” to store the encrypted 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 an encrypted password from the file “password.txt”. If the file exists and contains a string, the program should set the encrypted password in the password manager. Otherwise it should set the password in the password manager to “abc123@@@”.

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

2

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

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

The Validate Password option should ask the user to input the password. Then the main function should call the password manager to validate the password, and then the main function should output whether or not the password was valid (matching the one stored by the password manager) or not. If it was not valid, it should NOT repeat and ask the user to try again.

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

NOTES:

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

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

Put the Class declaration in the header file, the implementation of the class member functions in PasswordManager.cpp and the main function in PasswordDriver.cpp. Put a header comment at the top of each file.

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

constructor functions are NOT required.

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

3

• Your program must pass Test Case 0 or you will receive a score of 30 or less with no credit for the other grading categories (correctness/constraints/style). The input values and expected output are in a file called TC0.txt on the class website. This test case changes the password, then attempts to validate the new password (the password does not need to be saved to a file to pass TC0). Your program must contain a PasswordManager class to pass TC0.

Explanation / Answer

/* Definition: This program will request a password and verify

that it is a valid password. To be valid the password will

be at least six characters long and contain at least one digit.

*/

#include <iostream>

#include <cctype>

#include <string>

#include <ctype.h>

#include <stdio.h>

using namespace std;

const int SIZE = 50;

char password[SIZE]= {0};

bool verifypass(char *userinput,bool valid) //password verification function

{

valid = (1 == strcmp (userinput,password));

if (valid)

{

cout << "Thanks. That is a valid password." << endl;

}

return 0;

}

int verify_chars(char *userinput,bool valid)//verifies the number of characters

{

int length;

length = strlen(userinput); //checks for number of characters

if (length <=5)

{

valid=false;

cout << "Passwords must be at least 6 characters long" << endl;

}

else

{

valid =true;

  

}

return valid;

}

int main()

{

bool valid;

char userinput[50];

cout << "Please enter your password: " << endl;

cin >> userinput;

// Test the userinput for any digits in the string

bool digit_yes=false;

int num = 0;

int len = strlen(userinput);

for (int count = 0; count < len; count++)

if (isdigit(userinput[count]))   

digit_yes=true;

if (!digit_yes)

{

valid=false;

cout <<"Passwords must include at least one digit (1-9)"<< endl;

}

else

{

valid=true;

}

verify_chars(userinput,valid);// fuction designed to test the number of characters

verifypass(userinput,valid); // Funtion designed to strcmp the password and userinput

return 0;

}

note-the above code can help to solve the given query with required modifications.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote