-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsample.c
41 lines (32 loc) · 833 Bytes
/
sample.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* @file test.c
* @author Akagi201
* @date 2014/12/05
*
* test for url safe base64
*/
#include <stdio.h>
#include <string.h>
#include "b64.h"
int main(int argc, char *argv[]) {
char in[] = "bradley";
char out[256] = {0};
char res[256] = {0};
size_t len = 0;
size_t len_res = 0;
len = sizeof(out);
len_res = sizeof(res);
b64_encode(in, strlen(in), out, &len);
printf("b64_enc: %s\n", out);
b64_decode(out, len, res, &len_res);
printf("b64_dec: %s\n", res);
memset(out, 0, sizeof(out));
len = sizeof(out);
memset(res, 0, sizeof(res));
len_res = sizeof(res);
urlsafe_b64_encode(in, strlen(in), out, &len);
printf("urlsafe_b64_enc: %s\n", out);
urlsafe_b64_decode(out, len, res, &len_res);
printf("urlsafe_b64_dec: %s\n", res);
return 0;
}