All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
base64.h File Reference

Encode and decode data in base64 format. More...

#include <stddef.h>
#include <stdint.h>
+ Include dependency graph for base64.h:

Go to the source code of this file.

Macros

#define FR_BASE64_DEC_LENGTH(inlen)   ((3 * (inlen / 4)) + 2)
 
#define FR_BASE64_ENC_LENGTH(inlen)   ((((inlen) + 2) / 3) * 4)
 

Functions

ssize_t fr_base64_decode (uint8_t *out, size_t outlen, char const *in, size_t inlen)
 
size_t fr_base64_encode (char *out, size_t outlen, uint8_t const *in, size_t inlen)
 Base 64 encode binary data. More...
 
bool fr_is_base64 (char c)
 Check if char is in Base64 alphabet. More...
 

Detailed Description

Encode and decode data in base64 format.

Id:
ed67ead06c8dc02a1fe3c92c12ed09ede8de6de8
Author
Simon Josefsson

Definition in file base64.h.

Macro Definition Documentation

#define FR_BASE64_DEC_LENGTH (   inlen)    ((3 * (inlen / 4)) + 2)

Definition at line 39 of file base64.h.

#define FR_BASE64_ENC_LENGTH (   inlen)    ((((inlen) + 2) / 3) * 4)

Definition at line 38 of file base64.h.

Function Documentation

ssize_t fr_base64_decode ( uint8_t *  out,
size_t  outlen,
char const *  in,
size_t  inlen 
)

Definition at line 251 of file base64.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t fr_base64_encode ( char *  out,
size_t  outlen,
uint8_t const *  in,
size_t  inlen 
)

Base 64 encode binary data.

Base64 encode IN array of size INLEN into OUT array of size OUTLEN.

Parameters
[out]outWhere to write Base64 string.
[in]outlensize of buffer including NULL byte.
[in]inData to encode.
[in]inlenLength of data to encode.
Returns
  • Amount of data we wrote to the buffer.
  • -1 if output buffer was too small.

Definition at line 44 of file base64.c.

+ Here is the caller graph for this function:

bool fr_is_base64 ( char  c)

Check if char is in Base64 alphabet.

Note that '=' is padding and not considered to be part of the alphabet.

Parameters
cchar to check.
Returns
  • true if c is a character from the Base64 alphabet.
  • false if character is not in the Base64 alphabet.

Definition at line 223 of file base64.c.

+ Here is the caller graph for this function: