Program Specification: Using the techniques presented during this semester create a complete C++ program to emulate an Encryption/Decryption Machine. The machine will be capable of the following: V Encrypt a string entered by the user v Choose between two different encryption methods V Decrypt a string entered by the user v Choose between two different decryptions methods v Decrypt without knowing the encryption method (provide all possible outputs) The interface must be professional and fully intuitive to the user

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

The program is missing the ability to test for all 25 shifts as stated in the program requirements, the program isn't able to run with a error with the code also please fix this.

#include<iostream>

#include<stdio.h>

#include<string.h>

#include<conio.h>

 using namespace std;

class Substition// Substitution cipher class

{
 char str[500];

public :

 void sgetstring(void);  //method to get input string and key

 void senscryption(void); //ecryption method for substitution cipher

 void sedecryption(void); // decryption method for substitution cipher

};

void Substitution : : sgetstring()

{

int size=500;

cout<<"\n Enter the Input String: ";

cin.getline(str,size,'\n');

}

void  Substitution: :sencryption()

{

int key,i,t1;

char c;

cout<< "\n Enter Key:";

cin>> key;

cout<<"\n Encryption :";

//Encryption

for(i=0;i<strlen(str);i++)

{

c=str[i];

if(c==-1)

break;

if(isupper(c))

{

t1=(int)c - (int) 'A';

t1=(t1+key)%26;

t1=t1+(int) 'A';

cout<< (char)t1;

}

else if(islower(c))

{

t1=(int)c-(int) 'a';

t1=(t1+key) % 26;

t1=t1+(int) 'a';

cout<<(char)t1;

}

else{

cout<<c;

}

}

}

void Substitution: :sdecryption()

{

int key, i,t1;

char c;

cout<<"\n Decryption : \n";

//decryption

for(key=0;key<26;key++)

{

for(i=0;i<strlen(str); i++)

{

c=str[i];

if(c==-1)

break;

if(isupper(c))

{

t1=(int)c - (int) 'A';

t1=(t1-key +26) %26;

t1=t1+(int)'A';

cout <<(char)t1;

}

else if( islower(c))

{

t1=(int)c-(int)'a';

t1=(t1-key+26)%26;

t1=t1+(int) 'a';

cout<<(char)t1;

}

else

{

cout<<c;

}

}

cout<<"\n";

}

//ending

class Ceaser Cipher // Ceaser Ciper

{

char arr[22][22], darr[22][22], message[111],emessage[111],retmessage[111],key[55];

char temp[55], temp2[55];

public :

void tgetstring(); //method to get input string and key

void tencryption(); // ecryption method for ceaser cipher

void tdecryption(); // decryption method for ceaser cipher

void tcipher(int i, int c); //ceaser cipher module

int tfindMin();     //method to find the minimum values from the given key

void tmakeArray(int, int); // method to get the result encrypted/decrypted array

};

void CeaserCipher:: tgetstring()

{

cout<<"\n Enter the key\n";

cin.getline(key,111,'\n');

//gets(key);

cout<<"\n Enter message to be ciphered\n";

cin.getline(message,11,'\n');

//gets(message);

}

void CeaserCipher : : tencryption()

{

int i,j,klen, emlen, flag=0;

int r,c, index, rows, k=0;

strcpy_s(temp , key);

klen = strlen(key);

k=0;

for(i=0;;i++)

{

if(flag==1)

{

if(flag == 1)

break;

for(j=0; key[j]!='\0' ; j++)

{

if(message[k] == '\0')

{

flag=1;

arr[i][j]= '-';

}

else

{

arr[i][j]=message[k++];

}

}

}

r=i;

c=j;

for( i =0; i<r ; i++)

{

 for(j=0;j<c;j++)

{
cout << arr[i][j];

}

cout<<"\n";

}

cout << "\n Encrypted message is \n";

k=0;

for(i=0;i<klen; i++)

{

index = this->tfindMin();

this->tcipher(index,r);

}

emessage[k] = '\0';

//printf("\n Encrypted message is \n");

//for(i=0;i<strlen(emessage); i++)

//{

// printf("%c",emessage[i]);

//}

cout<<"\n\n";

void Ceaser Cipher : : tdecryption()

{

int i, j, klen, emlen , flag=0;

int r, c, index , rows, k;

// deciphering

emlen = strlen(message);

klen = strlen(key);

//emlen is length of encrypted message

strcpy_s(temp, key);

rows = emlen/ klen;

// rows is no of rows of the array to made from ciphered message

k=0;

for(i=0;; i++)

{
 if (flag==1)

break;

 for(j=0; key[j]! ='\0'; j++)

{

if(message[k] =='\0')

{

flag=1;

arr[i][j] = '-';

}

else

{

arr[i][j] = message[k++];

}

}

}

r=i;

c=j;

j=0;

for(i=0, k=1; i<emlen; i++, k++)

{

temp2[j++]=message[i];

if((k%rows) == 0)

{

temp2[j]='\0';

index = this->tfindMin();

this->tmakeArray(index, rows);

j=0;

}

}

cout<<"\n Array retrieved is \n";

k=0;

for(i=0;i<r; i++)

{

for(j=0;j<c ; j++)

}

cout<< darr[i][j];

//retrieving message

retmessage[k++]= darr[i][j];

}

cout<<"\n";

}

retmessage[k] = '\0';

cout<< "\ n Message retrieved is \n";

for( i=0; retmessage[i] !='\0';i++)

cout<<retmessage[i];

}

void CeaserCipher : : tcipher(int i , int r)

{

int j, k=0;

for(j=0; j<r; j++)

{

{

emessage[k++]=arr[j][i];

cout<< emssage[k-1];

}

}

//emessage[k]='\0';

}

void CeaserCipher : : tmakeArray(int col, int row)

{

int i, j;

for(i=0; i<row; i++)

{

darr[i][col] = temp2[i];

}

}

int CeaserCipher: : tfindMin()

{
int i,j,min, index;

min=temp[0];

index=0;

for(j=0;temp[j] ='\0'; j++)

{

if( temp[j] < min)

{

min =temp[j];

index=j;

}

}

temp[index]=123;

return(index);

}

//main method

int main(int argc, char** argv) 

{

int opa,ope;

char flag;

cout<<"\n select Algorithm : \n";

cout<<"\n 1. Substitution :";

cout<<"\n 2. CeaserCipher:";

cin >> opa;

fflush(stdin);

if(opa==1)

{
Substitution s;

cout<<" \n Substitution Cipher \n";

s.sgetstring();

cout<< "\n what do you want to perform:\n";

cout<<"\n 1.Encryption :";

cout<<"\n 2. Descryption : ";

cin >>ope;

if(ope ==1)

{

s.sencryption();

}

else

{

s.sdecryption();

}

(opa==2)

CeaserCipher t;

cout << "\n Ceaser Cipher \ n";

t.tgetstring();

cout<<"\n What do you want to perform : \n";

cout<< "\n 1.Encryption : ");

cout<<"\n 2.Decryption:";

cin>> ope;

if(ope==1)

{

t.tencryption();

}

else

{

t.tdecryption();

}

cout<<"\n\n\n Done";

//getch();

cin>>flag;

return(0);

}

Program Specification:
Using the techniques presented during this semester create a complete C++ program to emulate an
Encryption/Decryption Machine. The machine will be capable of the following:
V Encrypt a string entered by the user
v Choose between two different encryption methods
V Decrypt a string entered by the user
v Choose between two different decryptions methods
V Decrypt without knowing the encryption method (provide all possible outputs)
The interface must be professional and fully intuitive to the user
The program will be menu driven.
The program will use a class to define and implement each of the methods as member functions and will
store the original string and the encrypted/decrypted strings as data members.
In addition to using a class you must also use all the major structures we used this semester including:
Selection statements (if, if-else, switch) the appropriate one(s) of course
Loops (while, for, do-while) the appropriate one(s) of course
Standard Libraries (don't recreate the wheel)
Functions
Arrays
The two encryption/decryption methods are:
Substitution cipher
Caesar cipher
You will need to research each and determine how to implement them. Remember in the case of the
Caesar cipher there are 25 possible shifts, you must be able to choose or test for all 25 options.
Transcribed Image Text:Program Specification: Using the techniques presented during this semester create a complete C++ program to emulate an Encryption/Decryption Machine. The machine will be capable of the following: V Encrypt a string entered by the user v Choose between two different encryption methods V Decrypt a string entered by the user v Choose between two different decryptions methods V Decrypt without knowing the encryption method (provide all possible outputs) The interface must be professional and fully intuitive to the user The program will be menu driven. The program will use a class to define and implement each of the methods as member functions and will store the original string and the encrypted/decrypted strings as data members. In addition to using a class you must also use all the major structures we used this semester including: Selection statements (if, if-else, switch) the appropriate one(s) of course Loops (while, for, do-while) the appropriate one(s) of course Standard Libraries (don't recreate the wheel) Functions Arrays The two encryption/decryption methods are: Substitution cipher Caesar cipher You will need to research each and determine how to implement them. Remember in the case of the Caesar cipher there are 25 possible shifts, you must be able to choose or test for all 25 options.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Function Arguments
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education