ldas-tools-al 2.6.7
Loading...
Searching...
No Matches
Base64 Class Reference

Base 64 Conversion. More...

#include <base64.hh>

Static Public Member Functions

static size_t encode (std::string &Destination, const bit_vector &Source)
 Encode bit_vector.
 
static size_t encode (char *destination, const void *source, size_t size)
 Encode generic 8 bit data.
 
static size_t decode (bit_vector &Destination, const std::string &Source)
 Decode bit_vector.
 
static size_t decode (void *destination, const char *source)
 Decode generic 8 bit data.
 
static size_t calculateEncodedSize (size_t bytes)
 Compute number of output bytes given the number of input bytes.
 
static size_t calculateDecodedSize (const char *s)
 Compute number of output bytes given a null terminated string.
 
static void setNumCharactersPerLine (const int num)
 Establish the number of characters per line.
 
static size_t encode (std::string &Destination, const bit_vector &Source)
 Encode bit_vector.
 
static size_t encode (char *destination, const void *source, size_t size)
 Encode generic 8 bit data.
 
static size_t decode (bit_vector &Destination, const std::string &Source)
 Decode bit_vector.
 
static size_t decode (void *destination, const char *source)
 Decode generic 8 bit data.
 
static size_t calculateEncodedSize (size_t bytes)
 Compute number of output bytes given the number of input bytes.
 
static size_t calculateDecodedSize (const char *s)
 Compute number of output bytes given a null terminated string.
 
static void setNumCharactersPerLine (const int num)
 Establish the number of characters per line.
 

Detailed Description

Base 64 Conversion.

This class is used to convert to and from Base 64. Base 64 is a way to encode binary data using printable ASCII characters. It uses 4 characters for every 3 bytes.

This is a static class.

Member Function Documentation

◆ calculateDecodedSize()

size_t Base64::calculateDecodedSize ( const char * s)
static

Compute number of output bytes given a null terminated string.

Calculate Decoded Size.

Calculates the number of bytes which the passed Base-64 string will decode into.

Parameters
sThe string to check.
Returns
size_t The number of bytes.

◆ calculateEncodedSize()

size_t Base64::calculateEncodedSize ( size_t size)
static

Compute number of output bytes given the number of input bytes.

Calculate Encoded Size.

Calculates the number of characters required to represent the requested number of bytes in Base-64. This does not include the null-terminator.

Parameters
sizeThe number of bytes to encode.
Returns
size_t The size of the encoded string (minus the null-terminator).

◆ decode() [1/2]

size_t Base64::decode ( bit_vector & Destination,
const std::string & Source )
static

Decode bit_vector.

Decode base64 data back into a bit_vector

Parameters
DestinationStorage space for decoded data
SourceStorage space for the encoded data
Returns
size_t Number of bytes in the Destination buffer.

◆ decode() [2/2]

size_t Base64::decode ( void * destination,
const char * source )
static

Decode generic 8 bit data.

This translates a Base-64 encoded string into binary data.

Parameters
destinationThe location to write the decoded data. This must be large enough to store the data. The required size can be calculated via the 'calculateDecodedSize' method.
sourceBase64 data. Decoding will stop when the first non-Base64 character, an '=', or a null terminator occurs.
Returns
The number of bytes decoded.

◆ encode() [1/2]

size_t Base64::encode ( char * destination,
const void * source,
size_t size )
static

Encode generic 8 bit data.

Encodes Base64.

This method translates a block of binary data into Base-64 encoded data. The encoded data is stored in the memory location provided by the user. This destination buffer must be large enough to store the result. The user may calculate what the size needs to be via the calculateEncodedSize method (be sure to add 1 for the null character). This method appends a null character to the end of the encoded string.

Parameters
destinationThe buffer in which to store the encoded data.
sourceThe buffer to encode.
sizeThe number of bytes in the buffer.
Returns
The length of the destination string (not including the terminating null).

◆ encode() [2/2]

size_t Base64::encode ( std::string & Destination,
const bit_vector & Source )
static

Encode bit_vector.

Parameters
[out]DestinationThe buffer to hold the base 64 encoded result.
[in]SourceThe buffer holding the 8-bit data to encode.
Returns
The number of bytes written to Destination.

◆ setNumCharactersPerLine()

void Base64::setNumCharactersPerLine ( const int num)
static

Establish the number of characters per line.

Set number of characters per line.

Sets number of characters per line for the encoded data.

Parameters
numNumber of characters.
Returns
size_t The number of bytes.

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