Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with C++ code!!! Please do it in Encrypted.cpp, Encrypted.h, CypherA.h and CypherB.h. Focus more on CypherA.h and CypherB.h. Here is the main.cpp

Please help me with C++ code!!!

Please do it in Encrypted.cpp, Encrypted.h, CypherA.h and CypherB.h.

Focus more on CypherA.h and CypherB.h.

image text in transcribed

Here is the main.cpp:

// main.cpp

// Encrypted

//

#include

#include

#include

#include "CypherA.h"

#include "CypherB.h"

using namespace std;

int main(int argc, const char * argv[]) {

const int MAX_TEXT = 1000;

string filename;

cout

cin >> filename;

class CypherA messageA (filename, MAX_TEXT);

if (messageA.isEmpty())

{

cerr

}

else

{

messageA.decode();

cout

messageA.print();

cout

}

cout

cin >> filename;

class CypherB messageB (filename, MAX_TEXT);

if (messageB.isEmpty())

{

cerr

}

else

{

messageB.decode();

cout

messageB.print();

cout

}

return 0;

}

Here is the Encrypted.txt:

mr e wcqqixvmg irgvctxmsr epksvmxlq, fsxl xli wirhiv erh xli vigmtmirx ywi

xli weqi oic (orsar ew xli wigvix oic) xs irgvctx erh higvctx xli qiwweki.

sri zivc fewmg wcqqixvmg irgvctxmsr epksvmxlq mw orsar ew xli vsxexmsrep

gmtliv. mr xlmw epksvmxlq, xli wirhiv wmqtpc "ehhw" xli oic xs iegl

glevegxiv sj xli gpievxibx qiwweki xs jsvq xli gmtlivxibx. jsv ibeqtpi, mj

xli oic mw 2, "e" asyph figsqi "g", "f" asyph figsqi "h, erh ws sr. xli

vigmtmirx asyph xlir higvctx xli qiwweki fc "wyfxvegxmrk" xli oic jvsq

iegl glevegxiv sj xli gmtlivxibx xs sfxemr xli svmkmrep qiwweki.

Here is the Lab 4 code I have:

#include

#include

#include

using namespace std;

class Crypto

{

char *encrypted;

bool status;

int size;

public:

Crypto(char str[],int bytes)

{

encrypted=new char[bytes];

size=bytes;

ifstream fp;

fp.open(str);

int i=0;

status=true;

char c;

while( (c=fp.get()) != EOF)

{

if(i==bytes)

{

status=false;

break;

}

encrypted[i++]=c;

}

cout

fp.close();

}

bool getstatus()

{

return status;

}

void decode()

{

char key[]={'i','z','t','o','h','n','d','b','e','q','r','k','g','l','m','a','c','s','v','w','f','u','y','p','j','x'};

if(getstatus())

{

cout

for(int i=0;i

{

cout

}

}

else

{

cout

}

}

};

int main()

{

Crypto obj("data.txt",4);

obj.decode();

return 0;

}

LAB 5 - Abstract Class Encryption In this lab you will restructure and extend Lab 4 in order to have multiple encryption algorithms. You will create an abstract class with a pure virtual function decode which will be implemented in two different derived classes. One of them will have the algorithm that you already implemented in Lab 4. The second one is explained in STEP 3 STEP 1: Make the Encrypted class created for Lab 1 abstract. For a class to be abstract it needs to have a pure virtual function. Make decode a pure virtual function in that class (refer to textbook 15.7 Abstract Base Classes and Pure Virtual Functions). Keep everything that you already have in the Encrypted class except the implementation (body) of decode and any member variables used in the decoding process. Those need to be moved to the derived class where the decoding will now take place. Variables left in the base class that you may need to access in the derived classes need to be protected instead of private STEP 2: Create another header file "CypherAh" with class CypherA derived from Encrypted. Don't forget to #include Encrypted.h" in the new header file. Move the decode function that you implemented on Lab 4 here. This class should have: member function decode and any member variables needed in the decoding process constructor (refer to textbook 15.3 Constructors and Destructors in Base and Derived Classes and Passing Arguments to Base Class Constructors) and destructor. STEP 3: Create another header file Cypher&h with class CypherB derived from Encrypted. Don't forget to #include Encrypted.h". Implement another version of decode using an algorithm known as "rotational cypher". In this encryption method, a key is added to each letter of the original text. For example Cleartext: A P P LE 4 E T TP I Ciphertext: In order to decode, you need to subtract 4. Implement the member functions in CypherA and CypherB inline STEP 4: Now in main.cpp you cannot create objects of Encrypted anymore because you made it abstract and you cannot instantiate objects of abstract classes. Change main.cpp to create objects of CypherA and CypherB instead. You need to #include "CypherAh" and "CypherB.h" instead of "Encrypted.h" in main.cpp. Note that you can still call print and isEmpty on the objects of CypherA and CypherB, even though they belong to Encrypted, because CypherA and CypherB inherit all protected and public members from Encrypted Turn in Encrypted.cpp, Encrypted.h, CypherA.h and CypherB.h LAB 5 - Abstract Class Encryption In this lab you will restructure and extend Lab 4 in order to have multiple encryption algorithms. You will create an abstract class with a pure virtual function decode which will be implemented in two different derived classes. One of them will have the algorithm that you already implemented in Lab 4. The second one is explained in STEP 3 STEP 1: Make the Encrypted class created for Lab 1 abstract. For a class to be abstract it needs to have a pure virtual function. Make decode a pure virtual function in that class (refer to textbook 15.7 Abstract Base Classes and Pure Virtual Functions). Keep everything that you already have in the Encrypted class except the implementation (body) of decode and any member variables used in the decoding process. Those need to be moved to the derived class where the decoding will now take place. Variables left in the base class that you may need to access in the derived classes need to be protected instead of private STEP 2: Create another header file "CypherAh" with class CypherA derived from Encrypted. Don't forget to #include Encrypted.h" in the new header file. Move the decode function that you implemented on Lab 4 here. This class should have: member function decode and any member variables needed in the decoding process constructor (refer to textbook 15.3 Constructors and Destructors in Base and Derived Classes and Passing Arguments to Base Class Constructors) and destructor. STEP 3: Create another header file Cypher&h with class CypherB derived from Encrypted. Don't forget to #include Encrypted.h". Implement another version of decode using an algorithm known as "rotational cypher". In this encryption method, a key is added to each letter of the original text. For example Cleartext: A P P LE 4 E T TP I Ciphertext: In order to decode, you need to subtract 4. Implement the member functions in CypherA and CypherB inline STEP 4: Now in main.cpp you cannot create objects of Encrypted anymore because you made it abstract and you cannot instantiate objects of abstract classes. Change main.cpp to create objects of CypherA and CypherB instead. You need to #include "CypherAh" and "CypherB.h" instead of "Encrypted.h" in main.cpp. Note that you can still call print and isEmpty on the objects of CypherA and CypherB, even though they belong to Encrypted, because CypherA and CypherB inherit all protected and public members from Encrypted Turn in Encrypted.cpp, Encrypted.h, CypherA.h and CypherB.h

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

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions

Question

LO 25-2 What are the varieties of sexual behavior?

Answered: 1 week ago

Question

I had a problem last week; they would think I am picky or a whiner!

Answered: 1 week ago