In this assignment you will write a program that encrypts a text file. You will use the following encryption scheme. 1. Ask the user for the name of the original file. 2. Ask the user for the name of the output file. 3. Ask the user for the encryption key, n. 4. Read n² characters from the file into the n rows and n columns of a 2-dimensional array row by row. 5. Write the characters from the array to an output file column by column. 6. Repeat steps 4-6 until the entire input file has been read. This same program can be used to decrypt a file that has been encrypted in this way. Your program should have functions for performing the following tasks. 1) Reading the characters from the file into the array. This function should be passed the file stream, the array and the key. 2) Writing the characters from the array to the file. This function should be passed the file stream, the array and the key. Your main function should get the filenames, open the files, get the key, dynamically allocate the memory for the array, and close the files. Your program should also: Give detailed directions and warnings to the user. Be readable with appropriate documentation and formatting. (Be sure to include carefully written pre and post conditions for each of your functions)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
In this assignment you will write a program that encrypts a text file. You will use the following
encryption scheme.
1. Ask the user for the name of the original file.
2. Ask the user for the name of the output file.
3. Ask the user for the encryption key, n.
4. Read n² characters from the file into the n rows and n columns of a 2-dimensional array
row by row.
5. Write the characters from the array to an output file column by column.
6. Repeat steps 4-6 until the entire input file has been read.
This same program can be used to decrypt a file that has been encrypted in this way.
Your program should have functions for performing the following tasks.
1) Reading the characters from the file into the array. This function should be passed the
file stream, the array and the key.
2) Writing the characters from the array to the file. This function should be passed the file
stream, the array and the key.
Your main function should get the filenames, open the files, get the key, dynamically allocate the
memory for the array, and close the files.
Your program should also:
Give detailed directions and warnings to the user.
Be readable with appropriate documentation and formatting. (Be sure to include
carefully written pre and post conditions for each of your functions.)
Transcribed Image Text:In this assignment you will write a program that encrypts a text file. You will use the following encryption scheme. 1. Ask the user for the name of the original file. 2. Ask the user for the name of the output file. 3. Ask the user for the encryption key, n. 4. Read n² characters from the file into the n rows and n columns of a 2-dimensional array row by row. 5. Write the characters from the array to an output file column by column. 6. Repeat steps 4-6 until the entire input file has been read. This same program can be used to decrypt a file that has been encrypted in this way. Your program should have functions for performing the following tasks. 1) Reading the characters from the file into the array. This function should be passed the file stream, the array and the key. 2) Writing the characters from the array to the file. This function should be passed the file stream, the array and the key. Your main function should get the filenames, open the files, get the key, dynamically allocate the memory for the array, and close the files. Your program should also: Give detailed directions and warnings to the user. Be readable with appropriate documentation and formatting. (Be sure to include carefully written pre and post conditions for each of your functions.)
Expert Solution
steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education