C++ Base64编码/解码源代码

类别:编程语言 点击:0 评论:0 推荐:

inline int Base64Encode(char * base64code, const char * src, int src_len = 0);
inline int Base64Decode(char * buf, const char * base64code, int src_len = 0);

以上两个函数内联定义在base64.h中,使用时include "base64.h" 即可,编码后的长度一般比原文多占1/3的存储空间,为了效率,程序并没有检查目标存储区是否溢出,请保证有足够的存储空间。


源码下载:http://www.yanghan.net/codes/base64src.rar

示例代码输出如下:
[Base64]:
xOO6w6OsU25haVgNCg0KoaGhodXiysfSu7j2QmFzZTY0tcSy4srU08q8/qOhDQoNCkJlc3QgV2lzaGVz
IQ0KDQqhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhICAgICAgICAgICAgICAgZVNYPyENCqGhoaGh
oaGhoaGhoaGhoaGhoaGhoaGhoaGhoaEgICAgICAgICAgICAgICBzbmFpeEB5ZWFoLm5ldA0KoaGhoaGh
oaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoSAgICAgICAgIDIwMDMtMTItMjU=

[源文]:
你好,SnaiX

  这是一个Base64的测试邮件!

Best Wishes!

                             eSX?!
                             [email protected]
                          2003-12-25

参考资料:http://www.cstc.net.cn/docs/docs.php?id=202

本文地址:http://com.8s8s.com/it/it22090.htm