I try to use Base64 Encoder/Decoder. I encode a sample string("test string"), when I decode it I can't get the original string, last chracter is missing.
What's wrong here? :
- Code: Select all
#include <iostream>
#include <sstream>
#include "Poco/Base64Encoder.h"
#include "Poco/Base64Decoder.h"
#include "Poco/StreamCopier.h"
using Poco::Base64Encoder;
using Poco::Base64Decoder;
int main()
{
std::stringstream lStream,lStream2;
Base64Encoder encoder(lStream);
encoder<<"teststring";
std::string str;
lStream>>str;
std::cout<<"encoded:"<<str<<"\n";
Base64Decoder decoder(lStream2);
lStream2<<str;
decoder>>str;
std::cout<<"decoded:"<<str<<"\n";
}
Result:
------------------
encoded:dGVzdHN0cmlu
decoded:teststrin





