Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Base64 Class Reference
Base64 encoder and decoder. More...
#include <Base64.h>
Public Member Functions | |
| Base64 () | |
| Constructor. | |
| ~Base64 () | |
| Destructor. | |
| char * | Encode (const char *data, size_t input_length, size_t *output_length) |
| Encodes a string of information of a defined length. | |
| char * | Decode (const char *data, size_t input_length, size_t *output_length) |
| Decodes a base64 encoded stream back into the original information. | |
Detailed Description
Base64 encoder and decoder.
This class provided both encoding and decoding functions. These functions perform dynamic memory allocations to create space for the translated response. It is up to the calling function to free the space when done with the translation.
This code was derived from code found online that did not have any copyright or reference to its work.
Base64 n; size_t encodedLen; char *encoded = n.Encode("This is the message", 20, &encodedLen); printf("Encoded message is {%s}\r\n", encoded);
Definition at line 57 of file Base64.h.
Constructor & Destructor Documentation
| Base64 | ( | ) |
Constructor.
Definition at line 55 of file Base64.cpp.
| ~Base64 | ( | ) |
Destructor.
This will release memory that may have been allocated (when the Decode function was called).
Definition at line 60 of file Base64.cpp.
Member Function Documentation
| char * Decode | ( | const char * | data, |
| size_t | input_length, | ||
| size_t * | output_length | ||
| ) |
Decodes a base64 encoded stream back into the original information.
The information to decode is considered a base64 encoded stream. A length is provided which is used to compute the amount of memory to allocate for the conversion.
- Note:
- The Decode method does not know how you are using it - if it is for text, it will not apply any null termination, unless that was part of the input.
- Parameters:
-
data is a pointer to the encoded data to decode. input_length is the number of bytes to process. output_length is a pointer to a size_t value into which is written the number of bytes in the output.
- Returns:
- a pointer to the allocated block of memory holding the converted results.
- NULL if something went very wrong.
Definition at line 96 of file Base64.cpp.
| char * Encode | ( | const char * | data, |
| size_t | input_length, | ||
| size_t * | output_length | ||
| ) |
Encodes a string of information of a defined length.
The encoded information is considered a binary stream, therefore a length is provided which is used to compute the amount of memory to allocate for the conversion.
- Note:
- The Decode method does not know how you are using it - if it is for text, it will not apply any null termination, unless that was part of the input.
- Parameters:
-
data is a pointer to the input binary stream. input_length is the number of bytes to process. output_length is a pointer to a size_t value into which is written the number of bytes in the output.
- Returns:
- a pointer to the allocated block of memory holding the converted results.
- NULL if something went very wrong.
Definition at line 67 of file Base64.cpp.
Generated on Wed Jul 13 2022 20:26:22 by
1.7.2