void base64_encode_s(const unsigned char *str, long inlen, std::string& outstr, long* lpBufLen) { long len; long str_len; //unsigned char *res; //std::shared_ptr<std::string> res; int i,j; //定义base64编码表 const unsigned char *base64_table = (const unsigned char *)("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); //计算经过base64编码后的字符串长度 str_len= inlen; if(str_len % 3 == 0) len=str_len/3*4; else len=(str_len/3+1)*4; if (NULL != lpBufLen) { *lpBufLen = len; } //std::shared_ptr<std::string> res(new std::string(sizeof(unsigned char)*len+1)); //(unsigned char *)malloc(sizeof(unsigned char)*len+1); outstr.resize(sizeof(unsigned char)*len+1); outstr[len] = '