BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB-UTIL Reference

Base64 Encoding/Decoding

Macros

#define PJ_BASE256_TO_BASE64_LEN(len)   (len * 4 / 3 + 3)
 
#define PJ_BASE64_TO_BASE256_LEN(len)   (len * 3 / 4)
 

Functions

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

Detailed Description

This module implements base64 encoding and decoding.

Macro Definition Documentation

#define PJ_BASE256_TO_BASE64_LEN (   len)    (len * 4 / 3 + 3)

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

#define PJ_BASE64_TO_BASE256_LEN (   len)    (len * 3 / 4)

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

Function Documentation

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

Decode base64 string.

Parameters
inputInput string.
outBuffer to store the output. Caller must allocate this buffer with the appropriate size.
out_lenOn 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_base64_encode ( const pj_uint8_t input,
int  in_len,
char *  output,
int out_len 
)

Encode a buffer into base64 encoding.

Parameters
inputThe input buffer.
in_lenSize of the input buffer.
outputOutput buffer. Caller must allocate this buffer with the appropriate size.
out_lenOn 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.

 


PJLIB-UTIL Open Source, small footprint, and portable asynchronous/caching DNS resolver, text scanner, STUN client, and XML library
Copyright (C) 2006-2009 Teluu Inc.