Your functions are taking a const byte key[]
parameter, which is essentially treated as a pointer. thus sizeof(key) is the size of a pointer on your platform.
string encryptAES(const byte key[], const string& plain, const byte iv[])
// sizeof(key) is the size of a pointer
e.SetKeyWithIV(key, sizeof(key), iv);
You can use a std::vector<>
as an option, or pass the key_len, such as:
string encryptAES(const byte key[], size_t key_len, const string& plain, const byte iv[])
// using key_len for the length of the key
e.SetKeyWithIV(key, key_len, iv);
I hope that makes sense, because the same error is in a couple places.