Header only C++ AES cipher library.
#include "plusaes/plusaes.hpp"
#include <string>
#include <vector>
int main() {
const std::string raw_data = "Hello, plusaes";
const unsigned char iv[16] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
};
std::vector<unsigned char> encrypted(encrypted_size);
plusaes::encrypt_cbc((
unsigned char*)raw_data.data(), raw_data.size(), &key[0], key.size(), &iv, &encrypted[0], encrypted.size(),
true);
unsigned long padded_size = 0;
std::vector<unsigned char> decrypted(encrypted_size);
plusaes::decrypt_cbc(&encrypted[0], encrypted.size(), &key[0], key.size(), &iv, &decrypted[0], decrypted.size(), &padded_size);
}
std::vector< unsigned char > key_from_string(const char(*key_str)[17])
Definition: plusaes.hpp:697
unsigned long get_padded_encrypted_size(const unsigned long data_size)
Definition: plusaes.hpp:712
Error decrypt_cbc(const unsigned char *data, const unsigned long data_size, const unsigned char *key, const unsigned long key_size, const unsigned char(*iv)[16], unsigned char *decrypted, const unsigned long decrypted_size, unsigned long *padded_size)
Definition: plusaes.hpp:1043
Error encrypt_cbc(const unsigned char *data, const unsigned long data_size, const unsigned char *key, const unsigned long key_size, const unsigned char(*iv)[16], unsigned char *encrypted, const unsigned long encrypted_size, const bool pads)
Definition: plusaes.hpp:968