b64.h (820B)
1 // Minimal internal base64 (RFC 4648 alphabet), just enough for the asc armor. 2 // No external dependency; operates on length-bounded buffers. 3 4 #ifndef __SUPERCOP_FMT_ASC_B64_H__ 5 #define __SUPERCOP_FMT_ASC_B64_H__ 6 7 #include <stddef.h> 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 // Encodes in, wrapping lines at 64 columns with '\n', trailing '\n' included. 14 // Returns malloc'd buffer with *outlen set, or NULL on failure/empty input. 15 char *asc_b64_encode(const unsigned char *in, size_t len, size_t *outlen); 16 17 // Decodes in, skipping whitespace (space/tab/CR/LF). Expects correct '=' 18 // padding. Returns malloc'd buffer with *outlen set, or NULL on failure. 19 unsigned char *asc_b64_decode(const unsigned char *in, size_t len, size_t *outlen); 20 21 #ifdef __cplusplus 22 } // extern "C" 23 #endif 24 25 #endif // __SUPERCOP_FMT_ASC_B64_H__