base64.h (612B)
1 /* see LICENSE file for copyright and license details */ 2 #ifndef BASE64_H 3 #define BASE64_H 4 5 #include <stddef.h> 6 #include <stdint.h> 7 8 /* the length base64_encode writes for n bytes, its terminator not counted */ 9 #define BASE64_LEN(n) ((((n) + 2) / 3) * 4) 10 11 /* rfc 4648 base64 of in into out, terminated. returns the length */ 12 size_t base64_encode(char *out, const uint8_t *in, size_t n); 13 14 /* the bytes of the n characters of in, into out (cap bytes at most). 15 blanks are skipped. returns their number, -1 on a bad or long input */ 16 long base64_decode(uint8_t *out, size_t cap, const char *in, size_t n); 17 18 #endif