Question

This is to be written in C++. Thank you so much for you help as I'm...

This is to be written in C++. Thank you so much for you help as I'm really struggling with this.

Must be written in this format:

#include <stdio.h>

int main(void) {
printf("Hello World\n");
return 0;
}

The explosive growth of Internet communications and data storage on Internet-connected computers has greatly increased privacy concerns. The field of cryptography is concerned with coding data to make it difficult (and hopefully—with the most advanced schemes—impossible) for unauthorized users to read. In this exercise, you’ll investigate a simple scheme for encrypting and decrypting data. A company that wants to send data over the Internet has asked you to write a program that will encrypt it so that it may be transmitted more securely. All the data is transmitted as four-digit integers. Your application should read a four-digit integer entered by the user and encrypt it as follows: Replace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by 10. Then swap the first digit with the third, and swap the second digit with the fourth. Then print the encrypted integer. Write a separate application that inputs an encrypted four-digit integer and decrypts it (by reversing the encryption scheme) to form the original number.

Requirements:

- This assignment will essentially be two programs. You will write one program and submit it for encryption and one for the decryption and submit it. The requirements are generally the same. But, they are separate programs. I have provided requirements to make this easier than it might seem just reading the description.

- Define 4 integer variables, one for each of the numbers you are to encrypt.

- Prompt the user for each of the integers, with a new line after each prompt an example is like this:

Enter integer 1:(newline)

--read in value--

Enter integer 2:(newline)

--read in value--

Enter integer 3:(newline)

--read in value--

Enter integer 4:(newline)

--read in value--

As you saw in the example above, after each prompt, you will then read in the integer from the user.

For the encryption program, you will follow the encryption instructions from the description:

- Add 7 to the integer

- Get the remainder after dividing by 10

- When finished with the mathematical changes swap the first and last digit

For the decryption program, you will reverse the process:

- Swap the last and first

- Reverse the remainder

- Subtract 7

Finally, display the result:

- For Encryption: "The encrypted value is: --encrypted number--"(newline)

- For Decryption: "The decrypted value is: --decrypted number--"(newline)

Remember there are two programs: one for decrypt and one for encrypt.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

For encryption:

#include <iostream>

using namespace std;

int main()
{
//Variable declaration
int data[4], i, temp;
  
//Taking input from the user, adding 7 and getting the remainder
for(i = 0; i < 4; i++)
{
cout<<"Enter integer "<< i<<":"<<endl;
cin>>data[i];
  
data[i] = (data[i] + 7) % 10;
}
  
//Swapping
temp = data[0];
data[0] = data[2];
data[2] = temp;
  
temp = data[1];
data[1] = data[3];
data[3] = temp;


//Displaying the output
cout<<"The encrypted value is:"<<data[0]<<data[1]<<data[2]<<data[3];
}

For decryption

#include <iostream>

using namespace std;

int main()
{
//Variable declaration
int data[4], i, temp;
  
//Taking input from the user, adding 7 and getting the remainder
for(i = 0; i < 4; i++)
{
cout<<"Enter integer "<< i<<":"<<endl;
cin>>data[i];
}
  
//Swapping
temp = data[0];
data[0] = data[2];
data[2] = temp;
  
temp = data[1];
data[1] = data[3];
data[3] = temp;
  
//Reversing the remainder
for(i = 0; i < 4; i++)
{
data[i] = (data[i] + 3) % 10;
}
  
  
//Displaying the output
cout<<"The decrypted value is:"<<data[0]<<data[1]<<data[2]<<data[3];
}

Add a comment
Know the answer?
Add Answer to:
This is to be written in C++. Thank you so much for you help as I'm...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A company that wants to send data over the Internet has asked you to write a...

    A company that wants to send data over the Internet has asked you to write a program that will encrypt it so that it may be transmitted more securely. All the data is transmitted as four-digit integers. Your application should read a four-digit integer entered by the user and encrypt it as follows: Replace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by 10. Then swap the first...

  • program must be written in python and have commentary. thank you 3. File Encryption and Decryption...

    program must be written in python and have commentary. thank you 3. File Encryption and Decryption Write a program that uses a dictionary to assign "codes" to each letter of the alphabet. For example: codes-{A':'8','a' :'9', 'B' : e','b' :'#,, etc ) Using this example, the letter A would be assigned the symbol %, the letter a would be assigned the number 9, the letter B would be assigned the symbol e, and so forth. The program should open a...

  • I need Help to Write a function in C that will Decrypt at least one word with a substitution cipher given cipher text an...

    I need Help to Write a function in C that will Decrypt at least one word with a substitution cipher given cipher text and key My Current Code is: void SubDecrypt(char *message, char *encryptKey) { int iteration; int iteration_Num_Two = 0; int letter; printf("Enter Encryption Key: \n");                                                           //Display the message to enter encryption key scanf("%s", encryptKey);                                                                   //Input the Encryption key for (iteration = 0; message[iteration] != '0'; iteration++)                               //loop will continue till message reaches to end { letter = message[iteration];                                                      ...

  • Java Programming Part 1 File encryption is the science of writing the contents of a file...

    Java Programming Part 1 File encryption is the science of writing the contents of a file in a secret code. Your encryption program should work like a filter, reading the contents of one file, modifying the data into a code, and then writing the coded contents out to a second file. The second file will be a version of the first file, but written in a secret code. Although there are complex encryption techniques, you should come up with a...

  • Part 1 – Data Encryption Data Encryption is the process of transforming data, using a cipher,...

    Part 1 – Data Encryption Data Encryption is the process of transforming data, using a cipher, to make it unreadable to anyone except those possessing special knowledge. In this problem you will implement a simple encryption technique on data that comprises of non-negative integers that have at least six digits with no leading zeroes. In order to encrypt the number the following functions are to be implemented: void input(int *num); int add4(int num); int shift(int num); void printOutput(int encryptNum, int...

  • C program (Not C++, or C#) Viginere Cipher 1)Ask the user if we are encrypting or...

    C program (Not C++, or C#) Viginere Cipher 1)Ask the user if we are encrypting or decrypting. 2) Ask the user to enter a sentence to be transformed. 3) Ask the user to enter a sentence that will be used as the encryption or decryption key. 4) The sentences (array of characters) should end with a NULL terminator '\0'. 5) The range of values will be all printable characters on the ASCII chart starting with a SPACE - Value 32,...

  • 8. A company would like to encrypt a token that it uses to identify data. The...

    8. A company would like to encrypt a token that it uses to identify data. The token is a four digit integer. The encryption method is as follows- replace each digit with the result of adding 7 to the digit and getting the remainder by dividing the resulting value by 10. Write a method that will return the answer as a new four digit integer. Now, writea method that will DECRYPT the integer token you just created back to your...

  • Security is an important feature of information systems. Often, text is encrypted before being sent, and...

    Security is an important feature of information systems. Often, text is encrypted before being sent, and then decrypted upon receipt. We want to build a class (or several classes) encapsulating the concept of encryption. You will need to test that class with a client program where the main method is located. For this project, encrypting consists of translating each character into another character. For instance, if we consider the English alphabet, including characters a through z, each character is randomly...

  • Kindly follow the instructions provided carefully. C programming   Project 6, Program Design One way to encrypt...

    Kindly follow the instructions provided carefully. C programming   Project 6, Program Design One way to encrypt a message is to use a date’s 6 digits to shift the letters. For example, if a date is picked as December 18, 1946, then the 6 digits are 121846. Assume the dates are in the 20th century. To encrypt a message, you will shift each letter of the message by the number of spaces indicated by the corresponding digit. For example, to encrypt...

  • 1.     This project will extend Project 3 and move the encryption of a password to a...

    1.     This project will extend Project 3 and move the encryption of a password to a user designed class. The program will contain two files one called Encryption.java and the second called EncrytionTester.java. 2.     Generally for security reasons only the encrypted password is stored. This program will mimic that behavior as the clear text password will never be stored only the encrypted password. 3.     The Encryption class: (Additionally See UML Class Diagram) a.     Instance Variables                                                i.     Key – Integer...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT