当前位置: 首页 > 工具软件 > gear-lib > 使用案例 >

gear-lib的使用之libbase64

陈琪
2023-12-01

 

修改 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 

 

 类似资料: