AutoSeededRandomPool prng;
std::string plain("High-school students – who have been protesting against changes to colleges and the university system – also seized on the mood of protest and stepped up their blockades.");
std::string cipher_hex, recover1, recover2, cipher_bin;
SecByteBlock key(32), iv(32);
prng.GenerateBlock(key, key.size());
prng.GenerateBlock(iv, iv.size());
PanamaCipher<LittleEndian>::Encryption enc;
enc.SetKeyWithIV(key, key.size(), iv, iv.size());
PanamaCipher<LittleEndian>::Decryption dec;
dec.SetKeyWithIV(key, key.size(), iv, iv.size());
StringSource (plain, true, new StreamTransformationFilter(enc, new HexEncoder(new StringSink(cipher_hex))));
// works fine, recover1 = plain
StringSource (cipher_hex, true, new HexDecoder(new StringSink(cipher_bin)));
StringSource (cipher_bin, true, new StreamTransformationFilter(dec, new StringSink(recover1)));
dec.Resynchronize(iv, iv.size());
// does not work, recover2 = "High-school students – who have been protesting against changes –Ö)‘à« ç›áS` ¥¨~]Šm Qÿö:Û (...) "
StringSource (cipher_hex, true, new HexDecoder(new StreamTransformationFilter(dec, new StringSink(recover2))));