PebbleOS v4.47.0-512-g5285d4236
Loading...
Searching...
No Matches

Base64 encoding. More...

Functions

size_t pbl_base64_encode (char *out, size_t out_len, const void *data, size_t data_len)
 Encode data as standard (RFC 4648) padded base64.
 
int pbl_base64_decode (uint8_t *out, size_t out_len, const char *data, size_t data_len)
 Decode standard (RFC 4648) padded base64.
 

Detailed Description

Base64 encoding.

Function Documentation

◆ pbl_base64_decode()

int pbl_base64_decode ( uint8_t *  out,
size_t  out_len,
const char *  data,
size_t  data_len 
)

Decode standard (RFC 4648) padded base64.

out may be the same buffer as data, as decoding never gets ahead of its input.

Parameters
[out]outOutput buffer.
out_lenSize of out in bytes.
dataText to decode.
data_lenLength of data, a multiple of 4.
Returns
Number of bytes decoded.
Return values
-EINVALdata is not valid base64.
-ENOSPCout is too small.

◆ pbl_base64_encode()

size_t pbl_base64_encode ( char *  out,
size_t  out_len,
const void *  data,
size_t  data_len 
)

Encode data as standard (RFC 4648) padded base64.

Calling it with a too small out (e.g. out_len 0) returns the required length without writing anything.

Parameters
[out]outOutput buffer. Written only if it can hold the whole encoding; NUL-terminated when there is room left for the terminator.
out_lenSize of out in bytes.
dataData to encode.
data_lenNumber of bytes to encode.
Returns
Length of the encoding, excluding the NUL terminator.