Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this program, you will write a chunk based decryption program. Study the base code and make the following changes: Implement display_chunks(). Loop over each

For this program, you will write a chunk based decryption program. Study the base code and make the following changes:

Implement display_chunks(). Loop over each string in the array of message chunks (strings) and print it. Do not print the first character in each string since it is only used to store the order of the chunks. (Hint: use pointer arithmetic to skip a character.) [2 points]

Implement decrypt_chunks(). Loop over each string in the array and shift the characters in it by subtracting DECRYPTION_SHIFT value from them. Use pointer arithmetic to access individual characters but array access to the strings. Remember that C-style strings have a null terminator at the end. Do not apply the shift to the terminator. (Hint: to avoid doing double pointer arithmetic, save a char* pointer to the active chunk[?] in the outer loop but before the inner loop. Then the inner loop is only concerned with a single array of characters rather than an array of strings.) [3 points]

Implement sort_chunks(). Using your favorite sorting algorithm, sort the array containing the message chunks. Sort based on the first character in the chunk - it will always be a number. We provide a swap_strings function that you may use. Example usage: swap_strings(chunks[0], chunks[1]) will swap the contents of the first and second string. [10 points]

image text in transcribedimage text in transcribedimage text in transcribed

k * * (basic description of the program or class) * Completion time: (estimation of hours spent on this program) author (your name), (anyone else, e.g., Acuna, whose code you used) * @version (a version number or a date) //INCLUDES #include #include //macros: constants #define CHUNK-LENGTH (20+1) //each chunk has twenty characters, we add 1 so //there is space for the null terminator #define NUMBER OF CHUNKS 4 //the message is spread across 4 chunks. #define DECRYPTION-SHIFT 5 //this is the ASCII table shift used for decryption //forward declarations void sort chunks void decrypt_chunks) void display_chunks ().; char chunks [NUMBER_OF_CHUNKS ] [CHUNK_LENGTH]; int main(O f //copy message into memory. strcpy(chunks[aj, "211%fs1%fs%) stwrtzx%" ) ; strcpy (chunks [1], "1'H%nx%vznwp 1%kqflj"); //the format of a chunk s a single number indicating its order in overall //message followed by twenty encrypted characters

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions

Question

=+Where do you want to live and work?

Answered: 1 week ago

Question

=+1 Where are the best places in the world to live (and work)?

Answered: 1 week ago