93. Encrypting and decrypting files

In order to solve this problem with the Crypto++ library, we need to use several components:

  • FileSource, which allows reading data from a file using a BufferedTransformation. By default, it pumps data in blocks or chunks of 4,096 bytes, although manual pumping is also possible.
  • FileSink, which allows you to write data to a file using a BufferedTransformation. It is the companion sink object to a FileSource source object.
  • DefaultEncryptorWithMAC and DefaultDecryptorWithMAC, which encrypt and decrypt strings and files with an authentication tag to detect tampering. They use AES as the default block cipher and SHA256 as the default hash for the MAC. Each run through these two classes produces a different ...

Get The Modern C++ Challenge 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.