PcapPlusPlus  Next
pcpp::Base64 Class Reference

#include <GeneralUtils.h>

Static Public Member Functions

static std::string encode (const uint8_t *input, size_t inputLen)
 
static std::string encode (const std::string &input)
 
static std::string encodeHexString (const std::string &hexStringInput)
 
static std::string encode (const std::vector< uint8_t > &input)
 
static std::vector< uint8_t > decodeToByteVector (const std::string &input)
 
static std::string decodeToHexString (const std::string &input)
 
static std::string decodeToString (const std::string &input)
 
static size_t decodeToByteArray (const std::string &input, uint8_t *resultByteArr, size_t resultByteArrSize)
 
static size_t getDecodedSize (const std::string &input)
 

Detailed Description

A class for encoding and decoding strings/data using Base64 algorithm This implementation is based on the work by Tobias Locker, available at https://github.com/tobiaslocker/base64

Member Function Documentation

◆ decodeToByteArray()

static size_t pcpp::Base64::decodeToByteArray ( const std::string &  input,
uint8_t *  resultByteArr,
size_t  resultByteArrSize 
)
static

Decode a Base64 string to a byte array

Parameters
[in]inputThe Base64 string to be decoded
[out]resultByteArrA pre-allocated byte array where the result will be written to
[in]resultByteArrSizeThe size of the pre-allocated byte array
Returns
The size of the decoded data

◆ decodeToByteVector()

static std::vector<uint8_t> pcpp::Base64::decodeToByteVector ( const std::string &  input)
static

Decode a Base64 string to a vector of bytes

Parameters
[in]inputThe Base64 string to be decoded
Returns
The decoded vector of bytes

◆ decodeToHexString()

static std::string pcpp::Base64::decodeToHexString ( const std::string &  input)
static

Decode a Base64 string to a hex string

Parameters
[in]inputThe Base64 string to be decoded
Returns
The decoded hex string

◆ decodeToString()

static std::string pcpp::Base64::decodeToString ( const std::string &  input)
static

Decode a Base64 string to a regular string

Parameters
[in]inputThe Base64 string to be decoded
Returns
The decoded string

◆ encode() [1/3]

static std::string pcpp::Base64::encode ( const std::string &  input)
static

Encode a string to a Base64 string

Parameters
[in]inputThe string to be encoded
Returns
The encoded string

◆ encode() [2/3]

static std::string pcpp::Base64::encode ( const std::vector< uint8_t > &  input)
static

Encode a vector of bytes to a Base64 string

Parameters
[in]inputThe vector of bytes to be encoded
Returns
The encoded string

◆ encode() [3/3]

static std::string pcpp::Base64::encode ( const uint8_t *  input,
size_t  inputLen 
)
static

Encode an array of bytes to a Base64 string

Parameters
[in]inputThe array of bytes to be encoded
[in]inputLenThe length of the input array [in bytes]
Returns
The encoded string

◆ encodeHexString()

static std::string pcpp::Base64::encodeHexString ( const std::string &  hexStringInput)
static

Encode a hex string to a Base64 string

Parameters
[in]hexStringInputThe hex string to be encoded
Returns
The encoded string

◆ getDecodedSize()

static size_t pcpp::Base64::getDecodedSize ( const std::string &  input)
static

Get the expected decoded size of a Base64 string without actually decoding it

Parameters
[in]inputThe Base64 string to be decoded
Returns
The expected size of the decoded data