PcapPlusPlus
Next
|
A utility class for encoding and decoding data in Privacy-Enhanced Mail (PEM) format. More...
#include <PemCodec.h>
Static Public Member Functions | |
static std::string | encode (const std::vector< uint8_t > &data, const std::string &label) |
static std::vector< uint8_t > | decode (const std::string &pemData, const std::string &expectedLabel="") |
A utility class for encoding and decoding data in Privacy-Enhanced Mail (PEM) format.
The PemCodec class provides static methods to convert between binary data and PEM format, which is commonly used for cryptographic keys, certificates, and other security-related data. The PEM format uses base64 encoding with header and footer lines.
|
static |
Decodes PEM-encoded data back to its binary form
[in] | pemData | The PEM-encoded string to decode |
[in] | expectedLabel | Optional expected label that should be in the PEM header/footer. If provided and doesn't match, an exception will be thrown |
std::invalid_argument | if the input is not valid PEM format, if the label doesn't match or if base64 decoding fails |
|
static |
Encodes binary data into PEM format with the specified label
[in] | data | The binary data to be encoded |
[in] | label | The label to be used in the PEM header/footer (e.g., "CERTIFICATE", "PRIVATE KEY") |
std::invalid_argument | if the input data is empty or the label is empty |