Question

In: Computer Science

A company wants to transmit data over the telephone but is concerned that its phones could be tapped


A company wants to transmit data over the telephone but is concerned that its phones could be tapped. All of the data are transmitted as four-digit integers. The company has asked you to write a program that encrypts the data so that it can be transmitted more securely. Your program should read a four-digit integer and encrypt it as follows: Replace each digit by (the sum of that digit plus 7) modulus 10. Then, swap the first digit with the third, swap the second digit with the fourth and print the encrypted integer. Your main duty for this assignment is creating an Encrypt class which includes Encrypt.h and Encrypt.cpp. After finishing the task you can use CISP400V10A2.cpp to test the Encrypt class.

The following is the Encrypt class specification.

1. The Encrypt class has an integer private data member 8 element array named digits. The first four elements (0 ~ 3) are to store the original 4 digits integer and the next four (4 ~ 7) are to store the encrypted data.

2. Encrypt class has several public member functions

a. An Encrypt constructor takes an integer of any digits and stores the last four digits. It encrypts the last four digits, stores the encrypted information, displays a call to the constructor information, and shows the original information and encrypted information. If the inputted number is less than or equal to 0 the integer is set to 9436.

b. A displayOriginalData function does not accept and return any data. It displays the first four elements of the private data member.

c. A storeData function takes an integer and does not return anything. It stores the last four digits of the passed in integer to the first 4 elements of the private data member, encrypts the data and store them in the last 4 elements of the private data member.

d. A displayEncryptedData function does not accept and return any data. It displays the last four elements of the private data member.

Please document the files(CISP.cpp, Encrypt.cpp and Encrypt.h)

Solutions

Expert Solution

Encrypt.h

#include
#include
using namespace std;

class Encrypt
{
int digits[8];
public:
Encrypt(int val);
void displayEncryptedData();
void storeData(int val);
void displayOriginalData();
void swap();
};

Encrypt.cpp

#include "Encrypt.h"
Encrypt::Encrypt(int val)
{
cout<<"Constructor called"< if(val<=0)
val = 9436;
storeData(val);
displayOriginalData();
displayEncryptedData();
}

void Encrypt::displayEncryptedData()
{
cout<<"Encrypted Data"< for(int i=4;i<8;i++)
{
cout< }
cout< }


void Encrypt::storeData(int val)
{
string str = to_string(val).substr(to_string(val).length()-4,4);
int num = stoi(str);
int i=3;
while(num>0)
{
digits[i] = num%10;
num = num/10;
i--;
}
for(int j=0,k=4;k<8;k++,j++)
{
digits[k] = (digits[j]+7)%10;
}
swap();
}

void Encrypt::swap()
{
int temp = digits[4];
digits[4] = digits[6];
digits[6] = temp;

temp = digits[5];
digits[5] = digits[7];
digits[7] = temp;

}

void Encrypt::displayOriginalData()
{
cout<<"Original Data"< for(int i=0;i<4;i++)
{
cout< }
cout< }

int main()
{
Encrypt e(12345678);
return 0;
}

output


Related Solutions

A company wants to transmit data over the telephone, but is concerned that its phones could be tapped. All of the data are transmitted as four-digit integers.
  A company wants to transmit data over the telephone, but is concerned that its phones could be tapped. All of the data are transmitted as four-digit integers. The company has asked you to write a program that encrypts and decrypts the data so that it can be transmitted more securely. Your program should read a four-digit integer and encrypt it as follows: Replace each digit by (the sum of that digit plus 7) modulus 10. Then, swap the first...
A sender wants to transmit 16 frames in data link layer to a receiver, and every...
A sender wants to transmit 16 frames in data link layer to a receiver, and every 4th transmission is lost. How many total transmissions are required if A) Go-back-3 flow control is used? B) Selective repeat is used? C) Stop-and-wait is used?
An electronics company wants to compare the quality of their cell phones to the cell phones from three competitors.
  1. An electronics company wants to compare the quality of their cell phones to the cell phones from three competitors. They sample 10 phones from each company and count the number of defects for each phone. If ANOVA was used to compare the average number of defects, then the treatments would be defined as: Select one: a. The three companies b. The total number of phones c. The number of cell phones sampled d. The average number of defects 2....
A telephone company claims that 20% of its customers have a landline telephone. The company selects...
A telephone company claims that 20% of its customers have a landline telephone. The company selects a random sample of 500 customers and finds that 88 have a landline. At a .05 level of significance, is the company’s claim valid. Use the P-value approach. Clearly state the null and alternative hypothesis, locate the claim and state the decision.
A telephone company claims that 20% of its customers have a landline telephone. The company selects...
A telephone company claims that 20% of its customers have a landline telephone. The company selects a random sample of 500 customers and finds that 88 have a landline. At a .05 level of significance, is the company’s claim valid. Use the P-value approach. Clearly state the null and alternative hypothesis, locate the claim and state the decision.
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...
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...
1. A company that wants to send data over the Internet will use an encryption program...
1. A company that wants to send data over the Internet will use an encryption program to ensure data security. All data will be transmitted as four-digit integers. The application should read a four-digit integer entered by the user and encrypt it as follows:  Replace each digit with the remainder of the new value divided by 10 by adding 6 to the digit. Then replace the number in the first digit with the third, and the number in the...
1) A company that wants to send data over the Internet will use an encryption program...
1) A company that wants to send data over the Internet will use an encryption program to ensure data security. All data will be transmitted as four-digit integers. The application should read a four-digit integer entered by the user and encrypt it as follows:  Replace each digit with the remainder of the new value divided by 10 by adding 6 to the digit. Then replace the number in the first digit with the third, and the number in the...
1. A company that wants to send data over the Internet will use an encryption program...
1. A company that wants to send data over the Internet will use an encryption program to ensure data security. All data will be transmitted as four-digit integers. The application should read a four-digit integer entered by the user and encrypt it as follows:  Replace each digit with the remainder of the new value divided by 10 by adding 6 to the digit. Then replace the number in the first digit with the third, and the number in the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT