14.12 END OF CHAPTER PROGRAMS
14.12.1 Encrypt a file
Science of encryption was at its peak during World War II. Soldiers wanted their signals to be encrypted. Many scientists were involved in reverse process, which is decrypting the enemy messages. Today passwords in computers are encrypted. Let us study a simple program.
Problem: Read a text file and encrypt it.
Solution: There are sophisticated algorithms for encryption. Here we will use a simple bit-wise NOT operation. It normally converts a printable character into a non-printable one. Here we assume input file as “encr_inp.txt” and create output file “encr_out.txt”. See Program 14.12.
Program 14.12 File encryption
// encrypt.cpp#include<iostream.h>#include <fstream.h>#include <conio.h> ...
Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.