.. libencryptmsg documentation master file, created by sphinx-quickstart on Mon Feb 26 20:59:19 2018. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. :caption: Contents: :maxdepth: 1 LibEncryptMsg ------------- LibEncryptMsg is an open source library, written in C++, which provides encryption and decryption of data and implements OpenPGP specification. Features -------- * Symmetric encryption and decryption * Streaming: process large or gradually available data through a buffer * Compatibility with other OpenPGP solutions * Iterated and salted S2K * Cipher algorithms: CAST5, TripleDES, AES128, AES256 * Hash algorithms: SHA-1, SHA-256, SHA-512 * Integrity protection: SHA-1 * Compression: ZLIB, ZIP * Integration with Botan_ crypto library .. _Botan: https://botan.randombit.net Projects using this library --------------------------- EncryptPad_ - text editor and OpenPGP file encryption utility .. _EncryptPad: https://evpo.net/encryptpad/ Hello World example ------------------- .. code-block:: cpp :emphasize-lines: 16-20 #include #include "encryptmsg/message_encryption.h" int main(int argc, char **argv) { std::string pwd = "swordfish"; std::string plain_text = "hello world"; // EncryptMsg::SafeVector is STL vector with a custom allocator as below: // std::vector> EncryptMsg::SafeVector pwd_bytes(pwd.data(), pwd.data() + pwd.size()); EncryptMsg::SafeVector plain_bytes(plain_text.data(), plain_text.data() + plain_text.size()); EncryptMsg::SafeVector in_out_buffer = plain_bytes; EncryptMsg::MessageWriter writer; writer.Start(pwd_bytes); // Encrypt the buffer and notify that the stream is finished. We could also // call writer.Update(in_out_buffer) multiple times if streaming was needed writer.Finish(in_out_buffer); // Write the data to test.gpg std::ofstream file("test.gpg", std::ios_base::binary | std::ios_base::out); file.write(reinterpret_cast(in_out_buffer.data()), in_out_buffer.size()); return 0; } Decrypt test.gpg with GnuPG:: > echo -n "swordfish" | gpg2 --batch --passphrase-fd 0 -d test.gpg gpg: AES256 encrypted data gpg: encrypted with 1 passphrase hello world Community -------------- * General communication: `EncryptPad LibEncryptMsg community `_ * Issues and development: `GitHub `_ Downloads -------------- `GitHub releases `_ Build on Linux -------------- 1. Install the dependencies required to build C++ programs. Ubuntu needs ``build-essential``. 2. Install ``pkg-config``. 3. You will also need Botan 2. Ubuntu 18.04 Bionic has an official package: ``libbotan-2-dev``. If your distribution does not have Botan 2 package, you will need to build it and install (`link `_). 4. In the libencryptmsg source directory, run the three commands: :: ./configure.py [--prefix=/path/to/system/files] make sudo make install Sometimes you need to call ldconfig as below so that the system can resolve the new so file:: sudo ldconfig Link to the library ------------------- We will use the Hello World example above. 1. Copy the source code to ``enc_hello_world.cpp`` 2. Compile as below: :: g++ enc_hello_world.cpp $(pkg-config --cflags libencryptmsg) $(pkg-config --libs libencryptmsg) \ $(pkg-config --cflags botan-2) $(pkg-config --libs botan-2) Acknowledgments --------------- 1. `Botan `__ 2. `stlplus `__ 3. `Makefiles `__ 4. `zlib `__ 5. `gtest `__ 6. `plog `__ License ------- LibEncryptMsg Copyright 2018 Evgeny Pokhilko LibEncryptMsg is released under the `Simplified BSD License <_static/license.txt>`_