Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

File encryption is the science of writing the contents of a file in a secret cod

ID: 3645218 • Letter: F

Question

File encryption is the science of writing the contents of a file in a secret code. Your encryption
program should work like a filter, reading the contents of one file, modifying the information
into a code, and then writing the coded contents out to a second file. The second
file will be a version of the first file, but written in a secret code.
Although there are complex encryption techniques, you should come up with a simple one
of your own. For example, you could read the first file one character at a time, and add 10
to the ASCII code of each character before it is written to the second file.

Explanation / Answer

#include #include #include using namespace std; struct Encryptor { char operator()(char c) const { return c+10; } }; int main() { ifstream in("input.txt"); ofstream out("output.txt"); transform(istreambuf_iterator(in), istreambuf_iterator(), ostreambuf_iterator(out), Encryptor()); // or just bind1st(plus(), 10)); } sample run: $ cat input.txt abcdef 01234 $ ./test $ cat output.txt klmnop:;
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote