Question

In: Computer Science

Please solve all the following questions. I need the text file and screenshots of encryption and...

Please solve all the following questions. I need the text file and screenshots of encryption and decryption.

Exchange of encrypted data.

a. Encrypt a file (e.g., a text file) with an algorithm and a key length of your choice.

b. Exchange the file and the necessary credentials for decryption (i.e., algorithm, key) with your neighbor.

c. Decrypt the secret of your neighbor.

Solutions

Expert Solution

a.

To encrypt the file, we will use the modified Caesar cipher algorithm. In the modified Caesar cipher every character in the plaintext is moved by key number of places. Where key is common for both the sender and receiver.

Encryption:

Program:

#include <iostream>
#include <string.h>
using namespace std;

string encrypt(char text[], int s)
{
   string result = "";
   for (int i=0;i<strlen(text);i++)
   {
if(text[i]>='0'&&text[i]<='9')
{
result+=char(int(text[i]+s-48)%10+48);
}
       else if(text[i]>='A'&&text[i]<='Z')
{
result+=char(int(text[i]+s-65)%26+65);
}
else if(text[i]>='a'&&text[i]<='z')
{
result+=char(int(text[i]+s-97)%26+97);
}
else
{
result+=text[i];
}
   }
   return result;
}

int main()
{
   char plainText[100];
   int key;
   cout<<"Enter message: ";
   cin.getline(plainText,100);
   cout<<"Enter key: ";
   cin>>key;
   cout<<"\nPlain text : "<<plainText;
   cout<<"\nKey: "<<key;
   cout<<"\nEncrypted Text: "<<encrypt(plainText,key);
   return 0;
}

Screenshot of the Code:

Output:

b.

Message to share: Ymnx nx f xnruqj rjxxflj. 678

Key: 5

c.

Decryption:

#include <iostream>
#include <string.h>
using namespace std;

string decrypt(char text[], int s)
{
   string result = "";
   for (int i=0;i<strlen(text);i++)
   {
if(text[i]>='0'&&text[i]<='9')
{
result+=char(int(text[i]+s-48)%10+48);
}
       else if(text[i]>='A'&&text[i]<='Z')
{
result+=char(int(text[i]+s-65)%26+65);
}
else if(text[i]>='a'&&text[i]<='z')
{
result+=char(int(text[i]+s-97)%26+97);
}
else
{
result+=text[i];
}
   }
   return result;
}

int main()
{
   char text[100];
   int key;
   cout<<"Enter text to decrypt: ";
   cin.getline(text,100);
   cout<<"Enter key: ";
   cin>>key;
   cout<<"\nText to decrypt : "<<text;
   cout<<"\nKey: "<<key;
   cout<<"\nDecrypted Text: "<<decrypt(text,26-key);
   return 0;
}

Screenshot of the Code:

Output:


Related Solutions

Using OpenSSL from the command line interface. Please solve all the following questions. I also need...
Using OpenSSL from the command line interface. Please solve all the following questions. I also need the screenshots for every part. a. Create a text file with some input and encrypt it using i. AES-128 CBC ii. AES-256 CTR iii. DES b. Create a 2048 bit RSA public and private key
Dreamweaver, please i need all answers. questions 1 What is the standard file-naming convention for the...
Dreamweaver, please i need all answers. questions 1 What is the standard file-naming convention for the home page of a web site, or for the default page of a specific folder? O 1. main html O2index.html O 3. home.html O 4. any filename with the doc extension QUESTION 2 Which method can be used to create a hyperlink? 0. Use the Browse for File function in the Properties panel. 0. Use the Hyperlink button in the HTML Intern panel. 0....
I need an answer to all three questions, please. Q1: Which of the following was not...
I need an answer to all three questions, please. Q1: Which of the following was not a policy response to the Economic crisis associated with the COVID-19 Crisis? Select one: a. The Fed lowered the policy rate by roughly 1.5 percentage points to nearly zero. b. The U.S. Congress passed a roughly $3 Trillion economic stimulus package. c. The Commonwealth of Massachusetts relaxed the balanced budget rule in the State Constitution. d. The Fed introduced facilities to keep markets liquid...
Can you please solve these questions/ statements using python? I started with "importing" the file. I...
Can you please solve these questions/ statements using python? I started with "importing" the file. I only need question one to be answered not two-four. Can use whatever data frame of choice, I just need a sample code for each line. Thank you #1. #Fit a linear regression model on data: USA_housing.csv to predict the Price of the house. import pandas as pd housing_df = pd.read_csv("USA_Housing.csv") #Income: Avg. area income #Age: Avg age of the houses #Bedrooms: Avg No of...
My question below Write a complete program that performs encryption/decryption of a text file. Encryption means...
My question below Write a complete program that performs encryption/decryption of a text file. Encryption means you need to scramble the words of a file to become secure. Decryption means you need to apply some rules to an encrypted file in order to find the original file with its original content. An example of encryption is to replace each letter in a file with its consecutive letter in the alphabet. Therefore, ‘a’ is replaced by ‘b’, ‘b’ is replaced by...
I need to write a java program (in eclipse) that will read my text file and...
I need to write a java program (in eclipse) that will read my text file and replace specific placeholders with information provided in a second text file. For this assignment I am given a text file and I must replace <N>, <A>, <G>, with the information in the second file. For example the information can be John 22 male, and the template will then be modified and saved into a new file or files (because there will be multiple entries...
Please answer the below questions ( I need answers for all the below questions). Thank you...
Please answer the below questions ( I need answers for all the below questions). Thank you True or False Write true if the statement is true or false if the statement is false. _______ The heart consists mainly of muscle. _______ Blood pressure is highest in veins. _______ Atherosclerosis is the buildup of plaque inside arteries. _______ Platelets are blood cells that fight infections. _______ Peripheral gas exchange takes place in the lungs. _______ Food travels from the mouth to...
Please solve all of the questions, questions 1, 2, and 3. Please show all work and...
Please solve all of the questions, questions 1, 2, and 3. Please show all work and all steps. 1.) Find x(t) = Σ aktk such that tx'' = x 2.) Find x(t) = Σk>=0 aktk such that x'' = tx + 1 and x(0) = 0, x'(0) = 1 3.) Using the Frobenius method, solve t2x'' - 3tx' + (4-t)x = 0
Please solve the following questions. Please show all work and all steps. 1a.) Find CDF of...
Please solve the following questions. Please show all work and all steps. 1a.) Find CDF of the Bernoulli Distribution. 1b.) Explain your reasoning for part 1a above. Do not use a series result. 2a.) For the geometric distribution, show that the geometric pdf is actually a pdf (all probabilities are greater than or equal to 0 and the sum of the pdf from x=1 to x=infinity is equal to 1). 2b.) Find E(X) for 2a above. 2c.) Find V(X) for...
I need to know how to answer this question only in Excel. Please include instructions, screenshots,...
I need to know how to answer this question only in Excel. Please include instructions, screenshots, etc. in Excel which explain the process (formulas included). TropSun is a leading grower and distributer of fresh citrus products with three large citrus groves scattered around central Florida in the cities of Orlando, Eustis, and Winter Haven. TropSun currently has 275,000 bushels of citrus at the grove in Mt. Dora, 400,000 bushels at the groves in Eustis, and 300,000 bushels at the grove...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT