修改 test_libbase64.c 文件
#include "libbase64.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
char target[100], target2[100];
char source[]="hello world";
int ret_bytes=0;
ret_bytes = base64_encode(target, source, strlen(source));
target[ret_bytes]='\0';
printf("src size: %ld , return byte: %d , target: %s \n",strlen(source), ret_bytes, target);
ret_bytes = base64_decode( target2, target, ret_bytes);
target[ret_bytes]='\0';
printf("return byte: %d , target2: %s \n", ret_bytes, target2);
return 0;
}
编译运行
alen@ubuntu:/work/c/gear-lib/gear-lib/libbase64$ make
linux CC test_libbase64.o
linux CC test_libbase64
alen@ubuntu:/work/c/gear-lib/gear-lib/libbase64$ ./test_libbase64
src size: 11 , return byte: 16 , target: aGVsbG8gd29ybGQ=
return byte: 11 , target2: hello world