forked from cathugger/mkp224o
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base64.h
13 lines (13 loc) · 715 Bytes
/
base64.h
1
2
3
4
5
6
7
8
9
10
11
12
13
// converts src[0:slen] to base64 string
char *base64_to(char *dst,const u8 *src,size_t slen);
// calculates length needed to store data converted to base64
#define BASE64_TO_LEN(l) ((((l) + 2) / 3) * 4)
// converts src string from base64
size_t base64_from(u8 *dst,const char *src,size_t slen);
// calculates length needed to store data converted from base64
#define BASE64_FROM_LEN(l) ((l) / 4 * 3)
// validates base64 string and optionally stores length of valid data
// returns 1 if whole string is good, 0 if string contains invalid data
int base64_valid(const char *src,size_t *count);
// aligns data length to something base64 can represent without padding
#define BASE64_DATA_ALIGN(l) ((((l) + 2) / 3) * 3)