Question
Please Help Me With Task #4 As I Have Already Done Task #1: #include #include #include using namespace std; // Get the Ciphered Text string
Please Help Me With Task #4 As I Have Already Done Task #1:
#include
#include
#include
using namespace std;
// Get the Ciphered Text
string encrypt(string str, int);
// Decrypt the Cipher Text
string decrypt(string str, int);
int main() {
printf("Enter shift +/-26:");
int n;
cin>>n;
printf("Enter plaintext message (A-Z only, no spaces): ");
string str;
cin>>str;
// Get the Ciphered text
string cipher = encrypt(str,n);
// Decrypt the Cipher Text
string plaintext = decrypt(cipher,-n);
cout
return 0;
}
// Get the Cipher Text
string encrypt(string str,int n) {
int i;
for(i=0;i // Get the Ascii Code int ascii=(int)str[i]; ascii=ascii+n; if(ascii ascii=91-(65-ascii); else if(ascii>90) ascii=64+(ascii-90); // Update the Character With the Ciphered Text str[i]=(char)ascii; } return str; } // Decrypt the Cipher Text string decrypt(string str, int n) { int i; for(i=0;i // Get the Ascii Code int ascii=(int)str[i]; ascii=ascii+n; if(ascii ascii=91-(65-ascii); else if(ascii>90) ascii=64+(ascii-90); // Update the Character With the Ciphered Text str[i]=(char)ascii; } return str; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started