Question: Lab 4 In cryptography, encryption is the process of encoding a message or information in such a way that only authorized parties can access it.

Lab 4

In cryptography, encryption is the process of encoding a message or information in such a way that only authorized parties can access it. In this lab you will write a program to decode a message that has been encrypted.

Define a class with the following:

A variable to hold an encrypted message. This variable should be a c-string whose storage space will be allocated by the constructor.

A status variable that will tell whether the message was loaded successfully.

A constructor that receives two parameters: a string variable with the file name and an int variable with the maximum number of bytes that can be uploaded (use this parameter to dynamically allocate space for the variable that will hold the message). You must be careful to not read more characters than you allocated for the c-string variable or you risk having your program crash. After you successfully read the message from the file, set the value of the status variable to true.

A function that returns the value of the status variable. The value of this variable should always be checked prior to decoding, since trying to decode an empty string may result in your program crashing.

A function that decodes the message. Use the following key to decode:

input character: abcdefghijklmnopqrstuvwxyz

decoded character: iztohndbeqrkglmacsvwfuypjx

That means each 'a' in the input text should be replaced with an 'i', each 'b' with a 'z' and so forth.

A function that prints the message on the screen

I will provide a program that tests your class below

ifqkwxcadf ar cei fpoi masif cd cei xkdqirr du pxxnwafm pf pnmdkaceo cd p

oirrpmi, teaqe rqkpohnir cei gpcp af ac-oplafm ac sikw gauuaqvnc pfg caoi

qdfrvoafm, au fdc xkpqcaqpnnw aoxdrrahni, cd gigvqi cei dkamafpn masif

dfnw cei ifqdgig gpcp. afxvcr cd cei pnmdkaceo cwxaqpnnw afsdnsi

pggacadfpn riqkic gpcp qpnnig liwr, teaqe xkisifcr cei oirrpmi ukdo hiafm

giqdgig-isif au cei pnmdkaceo ar xvhnaqnw lfdtf.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!