It reads the clear text files generates a random key

  • No School
  • AA 1
  • 5

This preview shows page 4 - 5 out of 5 pages.

cipher text file names as arguments. It reads the clear text files, generates a random key, performs XOR on clear text and random key, producing the cipher text, and writes the random key and cipher text to file. When using malloc(), make sure to add 1 to the length of the string for the null char. Also, make sure to free() any allocated memory before the function returns. Sample function call for encrypt(): encrypt(clear_file, key_file, cipher_file); // Where the three arguments are strings containing filenames. The decrypt() function accepts the random key, cipher text and cipher text file names as arguments. It reads the random key and cipher text files. Read the random key and the cypher text using read_file. Sample function for decrypt(): decrypt(key_file, cipher_file, message_file); // Where the three arguments are strings containing filenames. Note: You must check if memory is successfully allocated and that files are opened successfully before using pointers to these objects. If a memory allocation or file open is unsuccessful, the pointer
Image of page 4

Subscribe to view the full document.

will be NULL. If a NULL pointer is found, you should provide an appropriate error message and terminate the program. You can test that the open file check works by passing a filename that does not exist.
Image of page 5

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes