base64code 的一个例子代码
2012-04-05 18:33
302 查看
#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; }
相关文章推荐
- .net下的IOCP代码例子[codeproject]
- 用装饰模式优化代码的一个简单例子
- Hibernate中对于数据的(增删改查)操作的一个例子的代码
- IOS一个滚动视图的小例子(代码)
- 重构代码的一个例子
- [置顶] yjh的实习生涯之自动化测试(2)---新建一个自动登录淘宝例子以及如何将java代码运行到手机上
- [CODE]牛津一美女写的一个PHOG代码
- 回文判断代码(可以忽略字符串中的空格,标点符号),举个例子啊,abcddcba就是一个回文。a b cd,dc ba也是一个回文。
- 一个初级例子讲述C和CPP在JNI中调用安卓Java代码
- SVM 自定义kernel的一个简单的code 例子
- 一个最基本的UDP通信代码例子
- 代码:cookie(一个广告展示例子)
- 如何调用一个程序,等待运行结束,并知晓程序运行成功与否:ShellExecuteEx;WaitForSingleObject;GetExitCodeProcess(C代码)
- C#BAD实践:学习如何通过坏的例子做一个好的代码
- 用几行代码做一个十分简单的无限循环播放的走马灯例子
- HTML5 Canvas旋转动画的2个代码例子(一个旋转的太极图效果)
- 添加一个记录到通讯录中的代码例子
- 一个OpenGL ES 的简单使用例子代码
- 快受不了了,本来想扒一个Wrox的权限管理的一个代码例子,VS2003的
- 一个imap的例子 - 参考,代码仅参考,复制后不可用