Group PJLIB_UTIL_BASE64

group PJLIB_UTIL_BASE64

This module implements base64 encoding and decoding.

Defines

PJ_BASE256_TO_BASE64_LEN(len)

Helper macro to calculate the approximate length required for base256 to base64 conversion.

PJ_BASE64_TO_BASE256_LEN(len)

Helper macro to calculate the approximage length required for base64 to base256 conversion.

Functions

pj_status_t pj_base64_encode(const pj_uint8_t *input, int in_len, char *output, int *out_len)

Encode a buffer into base64 encoding.

Parameters:
  • input – The input buffer.

  • in_len – Size of the input buffer.

  • output – Output buffer. Caller must allocate this buffer with the appropriate size.

  • out_len – On entry, it specifies the length of the output buffer. Upon return, this will be filled with the actual length of the output buffer.

Returns:

PJ_SUCCESS on success.

pj_status_t pj_base64url_encode(const pj_uint8_t *input, int in_len, char *output, int *out_len)

Encode a buffer into base64 (URL and Filename Safe) encoding.

Parameters:
  • input – The input buffer.

  • in_len – Size of the input buffer.

  • output – Output buffer. Caller must allocate this buffer with the appropriate size.

  • out_len – On entry, it specifies the length of the output buffer. Upon return, this will be filled with the actual length of the output buffer.

Returns:

PJ_SUCCESS on success.

pj_status_t pj_base64_decode(const pj_str_t *input, pj_uint8_t *out, int *out_len)

Decode base64 string.

Parameters:
  • input – Input string.

  • out – Buffer to store the output. Caller must allocate this buffer with the appropriate size.

  • out_len – On entry, it specifies the length of the output buffer. Upon return, this will be filled with the actual length of the output.

pj_status_t pj_base64url_decode(const pj_str_t *input, pj_uint8_t *out, int *out_len)

Decode base64 (URL and Filename Safe) string.

Parameters:
  • input – Input string.

  • out – Buffer to store the output. Caller must allocate this buffer with the appropriate size.

  • out_len – On entry, it specifies the length of the output buffer. Upon return, this will be filled with the actual length of the output.