Required function: void encrypt file(const std:string& filename, const std::stri
ID: 3885008 • Letter: R
Question
Required function: void encrypt file(const std:string& filename, const std::string& password) You realized that someone else might see through your idea to "unzip" a file and determine it is not secure enough to transmit these files, so you thought encryption might be a better way to secure your pictures. To do some basic encryption, you have decided to take a password as an encryption key and then repeatedly XOR the file data with the password and write out this data as a new file. To accomplish this, we have to understand first how XOR works. The bitwise operation in C++ is computed using the A operator works on all primitive types. The XOR operation behaves as follows: Table 1: Truth table for XOR (source: http://www.cplusplus.com/doc/boolean/) 011 101 1 1 0Explanation / Answer
The encrypt() function uses an array of 16 48-bit keys produced by the setkey() function to encode bytes specified by the block argument according to the Data Encryption Standard (DES) encryption algorithm or to decode argument bytes according to the DES decryption algorithm.
The block argument of encrypt() is an array of length 64 bytes containing only the bytes with numerical value of 0 and 1. The array is modified in place using keys produced by setkey(). If edflag is 0, the argument is encoded using the DES encryption algorithm. If edflag is 1 the argument is decoded using the DES decryption algorithm.
Special behavior for z/OS UNIX Services: The encrypt() function is thread-specific. Thus, for each thread from which the encrypt() function is called by a threaded application, the setkey() function must first be called from the thread to establish a DES key array for the thread.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.