I have to send a randomly generated number (rng) within a packet, and, thus, have to convert a SecByteBlock. I use libcrafter to put rng array into a RawLayer packet.
I followed this answer; but it gets me an invalid conversion error.
Here's the code I use:
AutoSeededRandomPool prng;
SecByteBlock rng1;
prng.GenerateBlock( rng1, rng1.size() );
string rng1_str(reinterpret_cast<char const*>(rng1));
std::string rng1_str = std::string(rng1.data(), rng1.size());
Crafter::RawLayer number(rng1_str);
The two ideas don't work, both give me:
error: invalid conversion from ‘CryptoPP::AllocatorWithCleanup<unsigned char>::pointer {aka unsigned char*}’
to ‘const char*’ [-fpermissive]
std::string rng1_str = std::string(rng1.data(), rng1.size());
Since the RawLayer accepts as constructor a std::string or a const byte*, I'd like to convert the SecBlockByte into one of these two formats...