LibJAD Web Routines

#include "jadweb.h"

Overview

Libjad provides a set of routines for web encoding and decoding.

unsigned char* base64_decode(char* b64, size_t* lenout)

b64The string to decode.
lenoutThis is an output variable. It contains the length of the returned buffer.
returnAn array of bytes containing the decoded data. Of size lenout.

Converts from base64 to binary. Ignores any character that is not part of the encoding, such as whitespace. Data to convert should be in b64 and null terminated. Returns a buffer filled with binary data and sets the value pointed at by length to the length of the returned data.

char* base64_encode(unsigned char* data, size_t length)

dataThe data buffer to encode.
lengthThe length of the buffer pointed to by data.
returnA null terminated string representing the data in base64.

Encode a buffer of binary data to a null terminated string containing the base64 representation. The returned buffer is does not contain line breaks or white space. It may need to be modified to confirm to PEM format or similar.

char* urlencode(char* data)

dataA null terminated string to encode.
returnA null terminated list of tokens (null terminated strings).

Encodes a null terminated string into url format. Returns a null terminated string containing the encoded version of data.

char* urldecode(char* data)

dataA null terminated string to decode.
returnA null terminated string.

Decodes a null terminated string in url format. Returns a null terminated string containing the decoded version of data.