Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is an encryption program. Modify the functions with an algorithm of a diffe

ID: 3535925 • Letter: T

Question

This is an encryption program. Modify the functions with an algorithm of a different design to encrypt/decrypt. The functions should follow the same format as below. They should accept a character array, combine it with the 16 byte key and manipulate it to some degree. Thank you

#include <iostream>

using namespace std;

#define BLOCK_SIZE 16


// Initialize key array, same size as data array

// The key is just an arbitary collection of bytes, it can be anything as long as they same key's used for encryption/decryption

const char key[] = "a@SDF23hds234u(D";


// Combines data bytes with key bytes then uses arbitary algorithm to jumble the data

void encrypt(char data[]) {

// Add the value of every index in the key to every index in the data array

for (int i = 0; i < BLOCK_SIZE; i++) {

data[i] = data[i] + key[i];

}


// Shift every member in the array left by 1

// So 0123456789012345 -> 1234567890123450

char first = data[0];

for (int i = 0; i < BLOCK_SIZE - 1; i++) {

data[i] = data[i + 1];

}

data[BLOCK_SIZE - 1] = first;

}


// Uses reverse of encryption algorithm to un-jumble data then seperates data bytes from key bytes

void decrypt(char data[]) {

// Shift every member in the array right by 1

// So 1234567890123450 -> 0123456789012345

char last = data[BLOCK_SIZE - 1];

for (int i = BLOCK_SIZE - 1; i >= 0; i--) {

data[i] = data[i - 1];

}

data[0] = last;


// Subtract the values of they key from the values of the data array

for (int i = 0; i < BLOCK_SIZE; i++) {

data[i] = data[i] - key[i];

}

}


int main() {

// Initialize data array

char data[] = "0123456789012345";


cout << "Encyption" << endl << endl << "[Data In]" << endl;

cout << data;

cout << endl << endl;


encrypt(data);


cout << "[Data Out]" << endl;

cout << data;

cout << endl << endl << endl;

cout << "Decryption" << endl << endl << "[Data In]" << endl;

cout << data;

cout << endl << endl;


decrypt(data);


cout << "[Data Out]" << endl;

cout << data;


cin.get();


return 0;

}

Explanation / Answer

https://www.google.com.pk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&ved=0CDkQFjAC&url=http://www.csupomona.edu/~hlin/CplusManual/CCplusmanual.pdf&ei=WLeMUdGpB4SNOIvAgJgC&usg=AFQjCNGDIhzD7qOravZHM6GJbG0xfYEAgw&bvm=bv.46340616,d.ZWU

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote