Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Object-Oriented Programming ********************************************************************************************************** A class called EncryptedString that stores a string in an encrypted format. Class Members The class should only have one private

C++

Object-Oriented Programming

**********************************************************************************************************

A class called EncryptedString that stores a string in an encrypted format.

Class Members

The class should only have one private data field of type string. This variable will store a string in an encrypted format. Do not store any other data in the EncryptedString object.

Class with publics method (member functions)

1) A default (no argument) constructor that stores an empty string in the data field.

2) A constructor that takes a string as a parameter and stores the encrypted version of the parameter in the data field. This method should not actually perform any "work". It should call the set method to encrypt and store the string.

3) A method called to set that takes a string as a parameter. It should encrypt the string parameter and store the result in the object.

Important: The method should discard any illegal characters in the string parameter. Remember that only alphabetic characters (upper and lower case letters A through Z) and space (blank) character are allowed in an EncryptedString. The easiest way to remove any illegal characters is to start with an empty string. Then add characters as you encrypt them, leaving out the illegal characters.

A method called get that returns a decrypted version of the string that is stored in the object. The returned value should be the same as the original string that was stored but with any illegal characters removed. This method should not change the encrypted string stored in the object.

method prototypes

EncryptedString();

EncryptedString( string str );

void set( string str );

string get();

Inside an EncryptedString object, only the encrypted version of a string is stored. Code outside the class will only see "normal" (unencrypted) strings. Each EncryptedString object is responsible for encrypting the string to be stored and decrypting the string before it is returned.

Prevent code from outside the class from "seeing" the encrypted version of the string. However, for debugging add one more public method class:

A method called getEncrypted that returns the string in encrypted format. This method should not change the encrypted string stored in the object.

The method prototype should be:

string getEncrypted();

Use a constant method, make get() and getEncrypted().

Encryption algorithm

The space character is not encrypted. A space is stored as a space.

An alphabetic character is replaced by its predecessor in the ASCII code sequence.

Exceptions: For encryption purposes, the predecessor of 'A' is 'Z', and the predecessor of 'a' is 'z'.

Decryption algorithm

The space character is not decrypted. A space is stored as a space.

An alphabetic character is replaced by its successor in the ASCII code sequence.

Exceptions: For decryption purposes, the successor of 'Z' is 'A', and the successor of 'z' is 'a'.

USE constants like 'A' makes your code much easier to read (as opposed to use ASCII codes like 65).

***********************************************************************************************************

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

Students also viewed these Databases questions