I\'m having a problem trying to convert SecByteBlock to string.
Here\'s my case:
I want to encrypt user access data using AES with static key and dynami
I'm having a problem trying to convert SecByteBlock to string
If the issue is with conversion from SecByteBlock and its byte array to a std::string and its char array, then you should:
SecByteBlock iv;
...
// C-style cast
std::string token = std::string((const char*)iv.data(), iv.size()) + userAccess;
Or,
SecByteBlock iv;
...
// C++-style cast
std::string token = std::string(reinterpret_cast(iv.data()), iv.size()) + userAccess;
You can also forgo the assignment, and just initialize and later append:
SecByteBlock iv;
...
std::string token(reinterpret_cast(iv.data()), iv.size());
...
std::string userAccess;
...
token += userAccess;
The other problem you might have is string to SecByteBlock. You should do this:
std::string str;
...
// C-style cast
SecByteBlock sbb((const byte*)str.data(), str.size());
Or:
std::string str;
...
// C++-style cast
SecByteBlock sbb(reinterpret_cast(str.data()), str.size());