# PBase64 Class Reference

This class is used to encode/decode data using the MIME standard base64 encoding mechanism as defined in RFC1521. More...

`#include <cypher.h>`

Inheritance diagram for PBase64:

List of all members.

## Public Member Functions

| PBase64 ()
| Construct a base 64 encoder/decoder and initialise both encode and decode members as in `StartEncoding()` and `StartDecoding()`.
void | StartEncoding (bool useCRLFs=true)
void | StartEncoding (const char *endOfLine)
void | ProcessEncoding (const PString &str)
void | ProcessEncoding (const char *cstr)
void | ProcessEncoding (const PBYTEArray &data)
void | ProcessEncoding (const void *dataBlock, PINDEX length)
PString | GetEncodedString ()
| Get the partial Base64 string for the data encoded so far.
PString | CompleteEncoding ()
| Complete the base 64 encoding and return the remainder of the encoded Base64 string.
void | StartDecoding ()
PBoolean | ProcessDecoding (const PString &str)
| Incorporate the specified data into the base 64 decoding.
PBoolean | ProcessDecoding (const char *cstr)
PBoolean | GetDecodedData (void *dataBlock, PINDEX length)
| Get the data decoded so far from the Base64 strings processed.
PBYTEArray | GetDecodedData ()
PBoolean | IsDecodeOK ()
| Return a flag to indicate that the input was decoded without any extraneous or illegal characters in it that were ignored.

## Static Public Member Functions

static PString | Encode (const PString &str, const char *endOfLine="\n")
static PString | Encode (const char *cstr, const char *endOfLine="\n")
static PString | Encode (const PBYTEArray &data, const char *endOfLine="\n")
static PString | Encode (const void *dataBlock, PINDEX length, const char *endOfLine="\n")
static PString | Decode (const PString &str)
| Convert a printable text string to binary data using the Internet MIME standard base 64 content transfer encoding.
static PBoolean | Decode (const PString &str, PBYTEArray &data)
static PBoolean | Decode (const PString &str, void *dataBlock, PINDEX length)

## Detailed Description

This class is used to encode/decode data using the MIME standard base64 encoding mechanism as defined in RFC1521.

To encode a large block of data use the following seqeunce:

          PBase64 base;
          base.StartEncoding();
          while (Read(dataChunk)) {
            base.ProcessEncoding(dataChunk);
            out << base.GetEncodedString();
          }
          out << base.CompleteEncoding();

if smaller blocks that fit easily in memory are to be encoded the `Encode()` functions can be used to everything in one go.

To decode a large block of data use the following sequence:

          PBase64 base;
          base.StartDecoding();
          while (Read(str) && ProcessDecoding(str))
            Write(base.GetDecodedData());
          Write(base.GetDecodedData());

if smaller blocks that fit easily in memory are to be decoded the `Decode()` functions can be used to everything in one go.

## Constructor & Destructor Documentation

PBase64::PBase64 | ( |  | ) |

Construct a base 64 encoder/decoder and initialise both encode and decode members as in `StartEncoding()` and `StartDecoding()`.

## Member Function Documentation

PString PBase64::CompleteEncoding | ( |  | ) |

Complete the base 64 encoding and return the remainder of the encoded Base64 string.

Returns:
  Base64 encoded string for the processed data.

static PBoolean PBase64::Decode | ( | const PString & | str,
|  | void * | dataBlock,
|  | PINDEX | length |
| ) |  |  | `[static]`

static PBoolean PBase64::Decode | ( | const PString & | str,
|  | PBYTEArray & | data |
| ) |  |  | `[static]`

static PString PBase64::Decode | ( | const PString & | str | ) | `[static]`

Convert a printable text string to binary data using the Internet MIME standard base 64 content transfer encoding.

The base64 string is checked and true returned if all perfectly correct. If false is returned then the string had extraneous or illegal characters in it that were ignored. This does not mean that the data is not valid, only that it is suspect.

Returns:
  Base 64 string decoded from input string.

static PString PBase64::Encode | ( | const void * | dataBlock,
|  | PINDEX | length,
|  | const char * | endOfLine = `"\n"` |
| ) |  |  | `[static]`

Parameters:

  dataBlock | Pointer to data to be encoded to Base64
  length | Length of the data block.
  endOfLine | String to use for end of line.

static PString PBase64::Encode | ( | const PBYTEArray & | data,
|  | const char * | endOfLine = `"\n"` |
| ) |  |  | `[static]`

Parameters:

  data | Data block to be encoded to Base64
  endOfLine | String to use for end of line.

static PString PBase64::Encode | ( | const char * | cstr,
|  | const char * | endOfLine = `"\n"` |
| ) |  |  | `[static]`

Parameters:

  cstr | C String to be encoded to Base64
  endOfLine | String to use for end of line.

static PString PBase64::Encode | ( | const PString & | str,
|  | const char * | endOfLine = `"\n"` |
| ) |  |  | `[static]`

Parameters:

  str | String to be encoded to Base64
  endOfLine | String to use for end of line.

PBYTEArray PBase64::GetDecodedData | ( |  | ) |

PBoolean PBase64::GetDecodedData | ( | void * | dataBlock,
|  | PINDEX | length |
| ) |  |  |

Get the data decoded so far from the Base64 strings processed.

Returns:
  Decoded data for the processed Base64 string.

PString PBase64::GetEncodedString | ( |  | ) |

Get the partial Base64 string for the data encoded so far.

Returns:
  Base64 encoded string for the processed data.

PBoolean PBase64::IsDecodeOK | ( |  | ) | `[inline]`

Return a flag to indicate that the input was decoded without any extraneous or illegal characters in it that were ignored.

This does not mean that the data is not valid, only that it is suspect.

Returns:
  Decoded data for the processed Base64 string.

PBoolean PBase64::ProcessDecoding | ( | const char * | cstr | ) |

PBoolean PBase64::ProcessDecoding | ( | const PString & | str | ) |

Incorporate the specified data into the base 64 decoding.

Returns:
  true if block was last in the Base64 encoded string.

void PBase64::ProcessEncoding | ( | const void * | dataBlock,
|  | PINDEX | length |
| ) |  |  |

void PBase64::ProcessEncoding | ( | const PBYTEArray & | data | ) |

void PBase64::ProcessEncoding | ( | const char * | cstr | ) |

void PBase64::ProcessEncoding | ( | const PString & | str | ) |

void PBase64::StartDecoding | ( |  | ) |

void PBase64::StartEncoding | ( | const char * | endOfLine | ) |

Parameters:

  endOfLine | String to use for end of line.

void PBase64::StartEncoding | ( | bool | useCRLFs = `true` | ) |

Parameters:

  useCRLFs | Use CR, LF pairs in end of line characters.

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

- cypher.h