35 lines
832 B
C++
35 lines
832 B
C++
#ifndef CFCB972C_1202_49D2_AAD4_9066BA17F94F
|
|
#define CFCB972C_1202_49D2_AAD4_9066BA17F94F
|
|
#include <iostream>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include "Poco/Base64Decoder.h"
|
|
#include "Poco/Base64Encoder.h"
|
|
#include "Poco/StreamCopier.h"
|
|
|
|
namespace Util
|
|
{
|
|
class Base64Util
|
|
{
|
|
private:
|
|
public:
|
|
static std::string base64Encode(const std::string& input)
|
|
{
|
|
std::ostringstream oss;
|
|
Poco::Base64Encoder encoder(oss, 0);
|
|
encoder.write(input.data(), input.size());
|
|
encoder.close();
|
|
return oss.str();
|
|
}
|
|
|
|
static std::string base64Decode(const std::string& input)
|
|
{
|
|
std::istringstream iss(input);
|
|
Poco::Base64Decoder decoder(iss);
|
|
std::ostringstream oss;
|
|
Poco::StreamCopier::copyStream(decoder, oss);
|
|
return oss.str();
|
|
}
|
|
};
|
|
}
|
|
#endif
|