3. Write a class to encrypt and decrypt a text file. The encryption step is described below:
a. Find N, where N is the length of the longest line in the file, or the number of lines in the file, whichever one is higher.
b. Find M, where M is and the next odd number bigger than or equal to N.
c. Allocate a two dimensional array of characters, of size MxM. Let’s call this array T. Initialize T so that all of its MxM element is a space character.
d. Fill each row of T with the corresponding line in the text file (row 0 filled with characters from the first line, starting from column 1, row 1 filled with characters from the second line, starting from column 1, row 2 filled with characters from the third line, starting from column 1, and so on..).
e. Write the content of T, starting from the center T[X][X], where X = M/2, and moving out in a spiral motion, counter clockwise, heading towards the left direction first, as shown in the diagram below:

T h e
q u i c k
b r o w n
f o x
i s v e r y
h u n g r y
t o n i g h t

Writing order:

Characters written:

The + sign are just to show you the number of spaces written, in your program you should write the space character, not write the + sign. Add the capability to decrypt as well. Your program should decrypt the encrypted file, and write the output to a new file, then compare this result with the original unencrypted file (ignore the space character during the comparison).

13 Years
Discussion Span
Last Post by alc6379

Come on now, folks.

Don't ask us to do your homework for you, and don't try to put a deadline on it. That's REALLY rude.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.