COSA
An Object-Oriented Platform for Arduino Programming
Base64 Class Reference

#include <Base64.hh>

Collaboration diagram for Base64:
Collaboration graph

Static Public Member Functions

static int encode (char *dest, const void *src, size_t size)
 
static int encode_P (char *dest, const void *src, size_t size)
 
static int encode (IOStream::Device *dest, const void *src, size_t size)
 
static int encode_P (IOStream::Device *dest, const void *src, size_t size)
 
static int decode (void *dest, const char *src, size_t size)
 

Detailed Description

Base64 encoder/decoder. Maps 3 bytes (24-bits) binary data to 4 printable characters, 32-bits. Allows encoding directly to an IOStream::Device such as the UART. Long string to an device is broken into multiple lines with a max length of 64 characters.

Acknowledgements

Inspired by implementation method by Bob Trower and Arduino Forum discussions.

References

  1. http://en.wikipedia.org/wiki/Base64
  2. https://tools.ietf.org/html/rfc4648
  3. http://base64.sourceforge.net

Definition at line 42 of file Base64.hh.

Member Function Documentation

int Base64::decode ( void *  dest,
const char *  src,
size_t  size 
)
static

Decode the size number of bytes in the source buffer to binary representation in the given destination buffer. The destination buffer must be able to hold the decoded data. The source buffer size must be even 4 character blocks (EINVAL is returned if not).

Parameters
[in]destdestination buffer pointer (binary).
[in]srcsource buffer pointer (string).
[in]sizenumber of bytes to decode.
Returns
number of decoded bytes or negative error code.

Definition at line 181 of file Base64.cpp.

int Base64::encode ( char *  dest,
const void *  src,
size_t  size 
)
static

Encode the size number of bytes in the source buffer to a null-terminated printable string in the given destination buffer. The destination buffer must be able to hold the encoded data and the terminating null.

Parameters
[in]destdestination buffer pointer (string).
[in]srcsource buffer pointer (binary).
[in]sizenumber of bytes to encode.
Returns
length of string or negative error code.

Definition at line 31 of file Base64.cpp.

int Base64::encode ( IOStream::Device dest,
const void *  src,
size_t  size 
)
static

Encode the size number of bytes in the source buffer to given iostream device. A new-line is emitted every 64 characters.

Parameters
[in]destoutput stream device.
[in]srcsource buffer pointer (binary).
[in]sizenumber of bytes to encode.
Returns
length of string or negative error code.

Definition at line 107 of file Base64.cpp.

int Base64::encode_P ( char *  dest,
const void *  src,
size_t  size 
)
static

Encode the size number of bytes in the source buffer to a null-terminated printable string in the given destination buffer. The destination buffer must be able to hold the encoded data and the terminating null. A new-line is emitted every 64 characters.

Parameters
[in]destdestination buffer pointer (string).
[in]srcsource buffer pointer (binary, in program memory).
[in]sizenumber of bytes to encode.
Returns
length of string or negative error code.

Definition at line 69 of file Base64.cpp.

int Base64::encode_P ( IOStream::Device dest,
const void *  src,
size_t  size 
)
static

Encode the size number of bytes in the source buffer to given iostream device.

Parameters
[in]destoutput stream device.
[in]srcsource buffer pointer (binary, in program memory).
[in]sizenumber of bytes to encode.
Returns
length of string or negative error code.

Definition at line 144 of file Base64.cpp.


The documentation for this class was generated from the following files: