From d900ae05d7eb66dd85ea21598b646d51ca56474a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 13 Feb 2009 14:54:13 +0000 Subject: [base64] Add base64 encoding functions --- src/include/gpxe/base64.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/include/gpxe/base64.h (limited to 'src/include') diff --git a/src/include/gpxe/base64.h b/src/include/gpxe/base64.h new file mode 100644 index 000000000..3321971a1 --- /dev/null +++ b/src/include/gpxe/base64.h @@ -0,0 +1,24 @@ +#ifndef _GPXE_BASE64_H +#define _GPXE_BASE64_H + +/** @file + * + * Base64 encoding + * + */ + +#include + +/** + * Calculate length of base64-encoded string + * + * @v raw_len Raw string length (excluding NUL) + * @ret encoded_len Encoded string length (excluding NUL) + */ +static inline size_t base64_encoded_len ( size_t raw_len ) { + return ( ( ( raw_len + 3 - 1 ) / 3 ) * 4 ); +} + +extern void base64_encode ( const char *raw, char *encoded ); + +#endif /* _GPXE_BASE64_H */ -- cgit v1.2.3-55-g7522