base64.h 715 B

12345678910111213
  1. // converts src[0:slen] to base64 string
  2. char *base64_to(char *dst,const u8 *src,size_t slen);
  3. // calculates length needed to store data converted to base64
  4. #define BASE64_TO_LEN(l) ((((l) + 2) / 3) * 4)
  5. // converts src string from base64
  6. size_t base64_from(u8 *dst,const char *src,size_t slen);
  7. // calculates length needed to store data converted from base64
  8. #define BASE64_FROM_LEN(l) ((l) / 4 * 3)
  9. // validates base64 string and optionally stores length of valid data
  10. // returns 1 if whole string is good, 0 if string contains invalid data
  11. int base64_valid(const char *src,size_t *count);
  12. // aligns data length to something base64 can represent without padding
  13. #define BASE64_DATA_ALIGN(l) ((((l) + 2) / 3) * 3)