#include "stdafx.h"
#include <string>
#include <iostream>
#include <vector>
#include <atlenc.h>
struct CartoonInfo
{
std::wstring strInfo;
};
typedef std::vector<CartoonInfo> VEC_CI;
VEC_CI g_vci;
void AddInfo(LPCWSTR info)
{
CartoonInfo ci;
ci.strInfo = info;
g_vci.push_back(ci);
}
int _tmain(int argc, _TCHAR* argv[])
{
LPCWSTR srcInfo = L"123";
std::string strSrc = (LPCSTR)CW2A(srcInfo);
int nSrcLen = strSrc.length()*2;
char *pDstInfo = new char[nSrcLen*2];
memset(pDstInfo, 0, nSrcLen*2);
int nDstLen = nSrcLen*2;
ATL::Base64Encode((BYTE*)strSrc.c_str(), nSrcLen, pDstInfo, &nDstLen);
AddInfo(CA2W(pDstInfo));
delete[] pDstInfo;
pDstInfo = NULL;
VEC_CI::iterator iter = g_vci.begin();
for(;iter!=g_vci.end(); ++iter)
{
long nSrcSize = (*iter).strInfo.size();
BYTE *pDecodeStr = new BYTE[nSrcSize];
memset(pDecodeStr, 0, nSrcSize);
int nLen = 100;
ATL::Base64Decode(CW2A((*iter).strInfo.c_str()), nSrcSize, pDecodeStr, &nLen);
std::wcout<<(char*)pDecodeStr<<std::endl;
delete[] pDecodeStr;
pDecodeStr = NULL;
}
return 0;
}