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

I don\'t know how to handle this C Programming encryption and decryption problem

ID: 648938 • Letter: I

Question

I don't know how to handle this C Programming encryption and decryption problem.

Thank you!

Encryption - build a C program that uses two keys to encrypt a text file in the following manner: Steps: 1. Break the input data into 16 bit chunks. 2. Break each 16 bit chunk into two 8 bit bytes (L and R). Then swap their places. (i.e. move the left byte to right, and the right to left.) 3. bitwise XOR the L byte and the 8 bit key for this iteration. 4. Repeat steps 2 and 3 again with the second key. 5. Assemble the output by glueing the 16 bit outputs back together. 6. If there is an odd number of bytes in the file (i.e. if you have 8 bits left over at the end of file) then bitwise XOR this extra byte with both keys but do not swap it with anything.

Explanation / Answer

steps:

1. Break the input data into 16 bit chunks.

2. Break each 16 bit chunk into 8 bit bytes(L abd R). Then swap their places.(i.e. move the left byte to right, and right byte to left)

3. Bitwise XOR the L byte and the 8 bit key for this iteration.

4. Repeat steps 2 and 3 again with the second key.

5. Assemble the output by glueing the 16bit outputs back together.

6. If there is an odd number of bytes in the file(i.e. if you have 8 bit left over at the end of file) then bitwise XOR this extra byte with keys but do not swap it with anything.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote