概述
参考网上的代码整理后的base64编解码,纯工具类代码。
static const char *ALPHA_BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
char *base64_encode (unsigned char *data, int size) {
char *d, buf[3];
int i, j, d_len;
if (!data || size <= 0)
return NULL;
d_len = size * 4 + 10;
d = (char *)malloc(d_len);
if (!d)
return NULL;
memset(d, 0, d_len);
for (i = 0, j = 0; i < size; ) {
buf[0] = data[i++];
buf[1] = i < size ? data[i++] : '