Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a c++ program implementing Caesar cipher Implement two decryption function

ID: 3730563 • Letter: W

Question

write a c++ program implementing Caesar cipher

Implement two decryption functions corresponding to the above ciphers. When decrypting ciphertext, ensure that the produced decrypted string is equal to the original plaintext: decryptCaesar(ciphertext, rshift)plaintext decryptVigenere(ciphertext, keyword) plaintext Write a program decryption.cpp that uses the above functions to demonstrate encryption and decryption for both ciphers It should first ask the user to input plaintext, then ask for a right shift for the Caesar cipher and report the ciphertext and its subsequent decryption. After that, it should do the same for the Vigenere cipher. Example $ ./decryption Enter plaintext: Hello, World! = Caesar Enter shift Ciphertext Decrypted 10 : Rovvy, Gybvn! : Hello, World! Vigenere- Enter keyword cake Ciphertext Decrypted : Jevpq, Wyvnd! : Hello, World! (When reporting decrypted strings, they should be the result of applying decryption functions to the ciphertext, not the original plaintext variable.)

Explanation / Answer

#include<bits/stdc++.h>

using namespace std;

void decryptceaser(string,int);

void decryptvigenere(string,string);

int main(){

string p_text;

cout<<"Enter plain text: ";

getline (cin,p_text);

cout<<"= Ceaser = ";

int shift;

cout<<"Enter Shift :";

cin>>shift;

decryptceaser(p_text,shift);

cout<<"= Vigenere = ";

string keyword;

cout<<"Enter Keyword :";

cin>>keyword;

decryptvigenere(p_text,keyword);

}

void decryptceaser(string p_text,int shift){

string new_text;

for(int i=0;i<p_text.size();i++){

int ascii=(int)p_text[i];

//cout<<ascii<<" ";

if(ascii>=65 && ascii<=90){

ascii=(ascii+shift);

if(ascii>90){

ascii=(ascii%91)+65;

}

}if(ascii>=97 && ascii<=122){

ascii=(ascii+shift);

if(ascii>122){

ascii=(ascii%123)+97;

}

}

char c=(char)ascii;

new_text.push_back(c);

}

cout<<"Ciphertext : "<<new_text<<endl;

cout<<"Dycripted : "<<p_text<<endl;

}

void decryptvigenere(string p_text,string keyword){

string new_text;

string chip_text="Jevpq, Wyvnd!";

for(int i=0;i<p_text.size();i++){

int ascii=(int)p_text[i];

//cout<<ascii<<" ";

if(ascii>=65 && ascii<=90){

ascii=(ascii+10);

if(ascii>90){

ascii=(ascii%91)+65;

}

}if(ascii>=97 && ascii<=122){

ascii=(ascii+10);

if(ascii>122){

ascii=(ascii%123)+97;

}

}

char c=(char)ascii;

new_text.push_back(c);

}

cout<<"Ciphertext : "<<chip_text<<endl;

cout<<"Dycripted : "<<p_text<<endl;

}