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.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 5RQ
icon
Related questions
Question

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 5 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning