Write a C++ program that will simulate a Change Password Utility. Your program will contain: One class, PasswordManager, that will manage a single password for a given username. A driver containing a main function that will allow the user to change their password.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

How do I make this program in C++? I've posted this before, but I've only gotten wrong answers.

Problem

Write a C++ program that will simulate a Change Password Utility.

Your program will contain:

  • One class, PasswordManager, that will manage a single password for a given username.
  • A driver containing a main function that will allow the user to change their password.

PasswordManager Class

The PasswordManager class should have two member variables (both strings):

  • a username
  • an encrypted password. Do not store the password (in the class or in a text file) 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 37 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 = ((ascii value of ch - 33) + 37) % 94 + 33

Store all the encrypted chars in a string and return it as the result of the function (hint: start with an empty string, use string.push_back(ch) to add each encrypted character).

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

  • it has at least 15 characters.
  • it contains at least three out of the following four types of characters:
    • uppercase (use isupper(ch))
    • lowercase (use islower(ch))
    • numbers (use isdigit(ch))
    • symbols (use ispunct(ch))
  • If the criteria are not met, it returns false.

The PasswordManager should have the following member functions that are accessible from outside of the class (from the driver):

setUsername: (a setter function) takes a string and stores it in the proper member variable.

getUsername: (a getter function) returns the value of the proper member variable.

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

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

setNewPassword: takes a string (a proposed, unencrypted, password). If it meets the criteria in meetsCriteria, it encrypts the password and stores it in the member variable and returns true. Otherwise returns false.

authenticate: 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.

Save the class declaration in PasswordManager.h and save the member function definitions in PasswordManager.cpp (do not inline the member function definitions).

Don't change names, parameters or return values of these methods. Otherwise you won't be able to pass all tests.

PasswordDriver

The main function should create an array of 4 instances of the PasswordManager class.

Your main function will ask for a filename to store the usernames and encrypted passwords in between executions of the program. This file simulates the stored encrypted passwords for users of a computer system. You can download a sample “passwords.txt” file from the 'Additional files' section of this assignment. When your main function starts, it should try to open the file with the filename you provided. If the file exists, you should assume it contains 4 usernames with encrypted passwords, and the program should use these to set the usernames and encrypted passwords in the password manager array. If the file doesn’t exist, exit with an error message.

Your program should ask the user to enter the filename, their netID, old password, and new password:

Please enter the name of the input file: passwords.txt Please enter your netID: j_s108 Please enter your old password: abcdABCD1234!@#$ Please enter your new password: jjjhFdjdhyas555

Your program should give one of the following responses:

NetID is invalid, password not changed. Old password is incorrect. New Password does not meet criteria. Password has been changed for netID: j_s108

If any of the input data is invalid or causes an error message, do NOT ask the user to re-enter the data.

After outputting one of the above responses to the screen, the program should output the usernames and three encrypted passwords to the file “passwords.txt”, one per line (overwriting anything that was previously in the file), then exit. However in order to simplify the testing procedure, please output this data directly to the screen instead.

There is a provided passwords.txt file with 4 sample usernames and encrypted password:(note that ()*+fghiVWXYFeHI is the encrypted version of abcdABCD1234!@#$).

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 7 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY