#include "EncryptionManager.h" EncryptionManager::EncryptionManager() { if (sodium_init() < 0) { throw std::runtime_error("libsodium init failed"); } } std::vector EncryptionManager::encrypt(const std::vector& raw) { randombytes_buf(key.data(), key.size()); randombytes_buf(nonce.data(), nonce.size()); std::vector crypt(raw.size()); if (crypto_stream_chacha20_ietf_xor_ic( reinterpret_cast(crypt.data()), reinterpret_cast(raw.data()), static_cast(raw.size()), nonce.data(), 0, key.data()) != 0) { throw std::runtime_error("crypto_stream_chacha20_ietf_xor_ic failed"); } return crypt; }