Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a C-program thats reads in a text-file(specified by the user, prefors a bit-level Exclusive-OR on each byte of the text-file (as a method of

Create a C-program thats reads in a text-file(specified by the user, prefors a "bit-level Exclusive-OR" on each byte of the text-file (as a method of encryption, then writes the encrypted file data back out to disk and gives the encryptd file the same name as the input file (overwrites the original file)

Application- Asks user to enter name of file to be encrypted

User- Enters name of file

Application- Encryps each bye of the input file and writes encrypted data back to the same file, over writing the orginal data.

image text in transcribedimage text in transcribed

Thank you!

#include int encrypt data (FILE int main (void) FILE *file ptr; int return code //get file name from user, then do fopen for reading & writing return code E encrypt data file ptr close (file ptr); return 0; int encrypt data (FILE *disk file ptr) int i Used to index through file buffer unsigned long int file size Holds number of bytes in the file int key length; Holds length of encryption key char *file buffer NULL char key Il "ABCDEF" default encryption key, you can change to //something else if you //want e.g. key 12Ygh9sss key length strlen (key) seek (disk file ptr, 0, SEEK END); Move file pointer to end of file file size ft ell (disk file ptr); Get current file pointer location (which will be the size of the file in bytes) rewind (disk file ptr); //Move file pointer back to beginning of file //Next step is to allocate RAM memory to hold all the bytes that are //currently stored on the HardDisk file buffer malloc (file size)

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

More Books

Students also viewed these Databases questions