Write a C++ class that will manage an encrypted password. Then write a C++ program to test the functionality of your class. Prior to writing your driver, submit a written test plan describing the boundary conditions that must be tested in order to have confidence that the PasswordManager is implemented correctly.
Your program will be composed of:
• A class, PasswordManager, that can manage a single password. The password manager validates that a user password complies with certain security restrictions (e.g., contains at least 8 characters), stores/loads the password to/from the hard drive in encrypted form only, and checks a user- ‐-entered password against the correct, saved password.
• A driver with a main() function that will test the PasswordManager class Your program should consist of the following files:
PasswordDriver.cpp (containing the main function)
You should also submit a Makefile that can be used to build the executable program in a Linux environment.
PasswordManager Class:
The PasswordManager class should have a single member variable (not accessible from outside the class), which stores the encrypted password (a string). Do NOT store the password in clear text (i.e., unencrypted) anywhere in the class! The PasswordManager class should have the following two internal member functions (NOT accessible outside of the class). You must name these functions exactly as described below, with only the described parameters!
• encrypt: This const function takes a password (a string) and returns the encrypted form of the password (also a string). Implement the following (trivial) “encryption”
For every character in the input string, encrypt the character by applying the XOR operator (^) with the int 26.
For example: str[i] ^ 26;
Store all of the encrypted chars in a new string to be returned as the result of the function. Do not change the argument that is passed in, and do not modify the class’s member variable.
• validatePassword: This const function takes a candidate password (a string) and returns true if it meets the following criteria: o it is at least 8 characters long
o it contains at least one uppercase letter o it contains at least one lowercase letter
o it contains at least one digit
o it contains at least one symbol character (non- ‐-digit, non- ‐-alphabetic, non‐-whitespace)
Otherwise it returns false.
The PasswordManager class should have the following five member functions that ARE accessible from outside of the class:
• getEncryptedPassword: This const “getter” function takes no arguments and returns the value of the encrypted password stored in the member variable. If the password has not yet been initialized, returns the empty string.
• setNewPassword: This mutator function takes a proposed password (a string). If the proposed password meets the criteria in validatePassword, this function encrypts the password, stores it in the member variable, and returns true.
Otherwise it returns false.
• checkPassword: This const function takes a clear text password (a string) and returns true if it matches the encrypted string stored in the member variable.
Otherwise it returns false. Note that since there is no decrypt function, we do not have the ability to decrypt the stored password. Therefore, this function must encrypt the input string in order to check it against the stored password.
• storeEncryptedPassword: This const function takes an output filename (a string). It opens the file, writes the member variable to file, then closes the file. This function returns true on success; false otherwise.
• loadEncryptedPassword: This mutator function takes an input filename (a string). It opens the file, reads the contents of the file into the member variable, and closes the file. No input validation is required; the assumption is that the file was written by storeEncryptedPassword. This function returns true on success; false otherwise.
Note that encrypted passwords can contain a space character, so you must read at least until the end of the first line of the input file.
Your main function should test the functionality of all public functions of your PasswordManager class, including all cases identified in your written test plan.
Similarly to my provided test driver for Project 3, the driver should print the following for each test case:
• The name of the function being tested, and/or a description of the case being tested
• The test data (the argument to the function call and/or a description of the scenario you’re creating)
• Expected driver output
• Actual driver output
Test Plan:
Your written test plan must include a description of at least one test case for each of the five member functions of PasswordManager that are accessible from outside the class.
Test the common case, of course; however, much of your test plan should focus on boundary conditions. (For example, what happens if the user attempts to set a new password with 7 characters?)
You do not have to test every possible input to your password manager. However, each of the five functions must have at least one associated test case, and you must make at least 10 function calls to PasswordManager member functions in your test driver.
For each test case, describe the input or behavior you intend to test and also describe expected output. For the function that writes to a file, your driver should independently read the file and print its output so that someone reading the driver output can compare expected and actual file contents. For the function that reads from a file, the driver should read the file independently of the PasswordManager class and verify that getEncryptedPassword returns the expected password after it is loaded.
Your test plan can be formatted any way you choose; please make it easy for me to identify which test cases are for which functions, and how many test cases there are in total.
Here’s an example of a possible format:
Test #1:
Function: checkPassword
Test precondition: The PasswordManager object has an initialized password, the cleartext version of which is “H3ll0 W@rld!”.
Test data: “H3llo W@rld!”
Expected behavior: checkPassword returns true (password accepted)
Additional requirements:
• Your submission MUST include a Makefile capable of compiling your PasswordManager.cpp, PasswordManager.h, and PasswordDriver.cpp files into a single executable. I recommend naming the executable file ‘password’.
• Do NOT change the names of the functions! Use the exact function names above, including uppercase/lowercase. Use exactly the return types and parameter types described above for each function.
• Be sure to declare all non- ‐-mutator member functions as const functions.
• Put the class declaration in the header file, the implementation of all class member functions in PasswordManager.cpp, and your test driver (main function) in PasswordDriver.cpp.
• Put a header comment at the top of each file.
• All console output must be done by your test driver. The PasswordManager class should not do ANY console input or output! (It can do file I/O as necessary to complete the loadEncryptedPassword and storeEncryptedPassword functions).
• Your class does not need to have constructors.
You may find the following information about the C++ string class helpful in completing this assignment. All of these assume that variable str is a string, ch is a char, and that you have #include’d <string> and <cctype>.
• If str is a string, you can access the i’th character in str using str[i]
• str.length() returns the length in characters of a string
• isupper(ch) returns true only if the character ch is an upper- ‐-case letter
• islower(ch) returns true only if the character ch is a lower- ‐-case letter
• isdigit(ch) returns true only if the character ch is a numeric digit
• ispunct(ch) returns true only if the character ch is not an alphabet, digit, or whitespace character
• You can append a new character ch to a string str with str += ch (the string length will be incremented automatically)

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.


#include <cstdlib>
#include <string>
#include <fstream>
#include <iostream>
#include <cctype>

using namespace std;

class PasswordManager {
    string getEncryptedPassword() const;
    bool setNewPassword(string password);
    bool checkPassword(string password) const ;
    bool storeEncryptedPassword(string fileName) const;
    bool loadEncryptedPassword(string fileName);...

By purchasing this solution you'll be able to access the following files:

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats