Core/Data/WebHelpers/base64.h File Reference
#include "WString.h"
Include dependency graph for Core/Data/WebHelpers/base64.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

size_t base64_min_encode_len (size_t in_len)
 Get minimum output buffer size required to encode message of given length. More...
 
size_t base64_min_decode_len (size_t in_len)
 Get minimum output buffer size required to decode message of given length. More...
 
int base64_encode (size_t in_len, const unsigned char *in, size_t out_len, char *out)
 encode binary data into base64 digits with MIME style === pads More...
 
String base64_encode (const unsigned char *in, size_t in_len)
 encode a block of data into base64, stored in a String More...
 
static String base64_encode (const String &in)
 encode a block of data into base64, both input and output are String objects More...
 
int base64_decode (size_t in_len, const char *in, size_t out_len, unsigned char *out)
 decode base64 digits with MIME style === pads into binary data More...
 
String base64_decode (const char *in, size_t in_len)
 decode base64 text into binary data More...
 
static String base64_decode (const String &in)
 encode a block of data into base64, both input and output are String objects More...
 

Function Documentation

◆ base64_decode() [1/3]

int base64_decode ( size_t  in_len,
const char *  in,
size_t  out_len,
unsigned char *  out 
)

decode base64 digits with MIME style === pads into binary data

Parameters
in_lenlength of source base64 text in characters
inbase64-encoded text
out_lensize of output buffer
outbuffer for decoded output
Return values
intlength of decoded output, or -1 if output buffer is too small

◆ base64_decode() [2/3]

String base64_decode ( const char *  in,
size_t  in_len 
)

decode base64 text into binary data

Parameters
insource base64-encoded text
in_lenlength of input text in characters
Return values
Stringthe decoded text

◆ base64_decode() [3/3]

static String base64_decode ( const String in)
inlinestatic

encode a block of data into base64, both input and output are String objects

Parameters
in
Return values
String

◆ base64_encode() [1/3]

int base64_encode ( size_t  in_len,
const unsigned char *  in,
size_t  out_len,
char *  out 
)

encode binary data into base64 digits with MIME style === pads

Parameters
in_lenquantity of characters to encode
indata to encode
out_lensize of output buffer
outbuffer for base64-encoded text
Return values
intlength of encoded text, or -1 if output buffer is too small
Note
Output is broken by newline every 72 characters. Final terminating newline is not included.

◆ base64_encode() [2/3]

String base64_encode ( const unsigned char *  in,
size_t  in_len 
)

encode a block of data into base64, stored in a String

Parameters
intext to encode
in_lenquantity of characters to encode
Return values
Stringthe base64-encoded text

◆ base64_encode() [3/3]

static String base64_encode ( const String in)
inlinestatic

encode a block of data into base64, both input and output are String objects

Parameters
in
Return values
String

◆ base64_min_decode_len()

size_t base64_min_decode_len ( size_t  in_len)

Get minimum output buffer size required to decode message of given length.

Parameters
in_lenLength of base64-encoded input message in characters
Return values
size_tNumber of characters required in output buffer

For decoding, do not assume that input is padded.

◆ base64_min_encode_len()

size_t base64_min_encode_len ( size_t  in_len)

Get minimum output buffer size required to encode message of given length.

Parameters
in_lenLength of input message in bytes
Return values
size_tNumber of bytes required in output buffer

Base-64 encodes 6 bits into one character (4 output chars for every 3 input bytes). However, it also requires padding such that the output size is a multiple of 4 characters.