Question: Please use C++ #include #include using namespace std; //xor operator ^: Hash code applied twice regenerates the original value: m is message character and h

Please use C++

#include #include

using namespace std;

//xor operator ^: Hash code applied twice regenerates the original value: m is message character and h is hash // x=m^h and y=x^h then y (decoded message) is the same as m

void coder(char *x, char key,int length); char *getMessage(char *request);

int main() { char *m = getMessage("Enter message to encode: "); int length = strlen(m); cout << length << endl; //char *k = getMessage("Enter key ");//read in a key of arbitrary length coder(m, 'A', length);//A is the key. Encode message with key string cout << m << endl; coder(m, 'A', length);//Decode message. Decode message with key string cout << m << endl; delete(m); //no leaks // delete(k); return 0; }

void coder(char *message, char key, int length)//make key an array { for (int i = 0; i < length; i++) message[i] = message[i]^key;//cycle through the key }

char *getMessage(char *request) { char temp[100], *p; cout << request << " "; cin >> temp; p = new char(strlen(temp)+1);//+1 for terminating null strcpy(p, temp); return p; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!