Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cBase64CoderT< _TYPE_CH > Class Template Reference

#include <cBase64.h>

Inheritance diagram for GrayLib::cBase64CoderT< _TYPE_CH >:
GrayLib::cUUCodeChar GrayLib::cBase64Coder

Static Public Member Functions

static bool IsValidChar (char ch) noexcept
 
static void EncodeBlock (char *pDstText, const BYTE *pSrcBin)
 
static void DecodeBlock (BYTE *pDstBin, const char *pSrcText) noexcept
 
static void EncodeBlockEnd (char *pDst, const BYTE *pSrc, size_t nSizeLeft)
 
static StrLen_t GRAYCALL Encode (char *pDstText, StrLen_t nLenDstMax, const BYTE *pSrcBin, size_t nSizeSrc)
 Encode a binary blob to text string. More...
 
static size_t GRAYCALL Decode (BYTE *pDstBin, size_t nSizeDst, const char *pSrcText, StrLen_t nLenSrc=-1)
 Decode an encoded text string to a binary blob. in place is OK. More...
 
- Static Public Member Functions inherited from GrayLib::cUUCodeChar
static char ENC (BYTE b)
 
static BYTE DEC (char ch) noexcept
 
- Static Public Member Functions inherited from GrayLib::cBase64Coder
static StrLen_t GetTextSizeFromBinarySize (size_t nSizeBin) noexcept
 
static size_t GetBinarySizeFromTextSize (StrLen_t nLenText) noexcept
 

Additional Inherited Members

- Public Member Functions inherited from GrayLib::cBase64Coder
 UNITTEST_FRIEND (cBase64)
 
- Static Public Attributes inherited from GrayLib::cUUCodeChar
static const char k_chFill = (char)(' ' + 64)
 

Detailed Description

template<class _TYPE_CH = cUUCodeChar>
class GrayLib::cBase64CoderT< _TYPE_CH >

This is a very simple binary<->text packer/unpacker. 3 to 4 ratio. NOT as nice/efficient as yEnc _TYPE_CH is the character encoder.

Member Function Documentation

◆ Decode()

template<class TYPE >
size_t GrayLib::cBase64CoderT< TYPE >::Decode ( BYTE *  pDstBin,
size_t  nSizeDst,
const char *  pSrcText,
StrLen_t  nLenSrc = -1 
)
static

Decode an encoded text string to a binary blob. in place is OK.

Decode a text string back to it's original binary form.

Note
All text must be valid encoded chars else failure. return ????
pDstBin==pSrcText compress/decode in place is OK.
Returns
Destination size_t (in bytes)

◆ DecodeBlock()

template<class _TYPE_CH = cUUCodeChar>
static void GrayLib::cBase64CoderT< _TYPE_CH >::DecodeBlock ( BYTE *  pDstBin,
const char *  pSrcText 
)
inlinestaticnoexcept

Take 4 encoded text chars in and output 3 binary bytes

Note
pDst==pSrc is OK. in place is OK 6 bits or 64 units of dynamic range is not that much.
If text input data is outside range then we are corrupted !!!

◆ Encode()

template<class TYPE >
StrLen_t GrayLib::cBase64CoderT< TYPE >::Encode ( char *  pDstText,
StrLen_t  nLenDstMax,
const BYTE *  pSrcBin,
size_t  nSizeSrc 
)
static

Encode a binary blob to text string.

Encode a binary array to text format. Take 3 bytes in and output 4 text.

Note
pDstText==pSrcBin expand/encode in place is OK.
IF Last 3 bytes are not properly aligned, should be padded with '=' k_chFill
Returns
output length in characters. (always multiple of 4)

◆ EncodeBlock()

template<class _TYPE_CH = cUUCodeChar>
static void GrayLib::cBase64CoderT< _TYPE_CH >::EncodeBlock ( char *  pDstText,
const BYTE *  pSrcBin 
)
inlinestatic

Take 3 binary bytes in and output 4 text chars

Note
pDst==pSrc is OK. in place is OK

◆ EncodeBlockEnd()

template<class _TYPE_CH = cUUCodeChar>
static void GrayLib::cBase64CoderT< _TYPE_CH >::EncodeBlockEnd ( char *  pDst,
const BYTE *  pSrc,
size_t  nSizeLeft 
)
inlinestatic

◆ IsValidChar()

template<class _TYPE_CH = cUUCodeChar>
static bool GrayLib::cBase64CoderT< _TYPE_CH >::IsValidChar ( char  ch)
inlinestaticnoexcept

Is this a valid encoded Base64/UUcode char ? A-Z, a-z, 0-9, +/, with = used for padding. (64)


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