TinyAES++  v0.0.1-2438
C++ API for TinyAES
TinyAES++ Documentation

The detailed documentation for TinyAES++ can be found within the TinyAES namespace.  

There are two central functions:

To encrypt and decrypt, you'll also need a 256-bit key and a 128-bit initialization vector. The simplest way to create them is with:

cbc_encrypt() and cbc_decrypt() can work with either std::string, or with vectors of bytes called TinyAES::VBytes.

Here is a simple example showing how to create a key and iv, then encrypt and decrypt a text string:

#include <TinyAES.hpp>
// ...
const std::string original_text = "Hello, world!";
// this next function call does both the PKCS padding and encrypts the text
const std::string encrypted = TinyAES::cbc_encrypt(original_text, key, iv);
// do not try to print "encrypted", it is binary data
// this next function call decrypts the text and removes the padding that was added during encryption
const std::string decrypted = TinyAES::cbc_decrypt(encrypted, key, iv);
std::cout
<< "256-bit key: " << TinyAES::to_hex_string(key) << std::endl // 32 bytes of hex data
<< "128-bit iv: " << TinyAES::to_hex_string(iv) << std::endl // 16 bytes of hex data
<< "Original text: " << original_text << std::endl // "Hello, world!"
<< "Original text length: " << original_text.size() << std::endl // 13
<< "Encrypted text length: " << encrypted.size() << std::endl // 16 (due to padding)
<< "Decrypted text: " << decrypted << std::endl; // "Hello, world!"