Encoding
Encoding is very simple, say we had some data 'pData'
that was of length 'dwLen', that we wished to encode
and store in 'pData2' which is of length 'dwLen'*2,
then
#include "hex.h" // from crypto++ library
HexEncoder hexEncoder;
hexEncoder.Put(pData,dwLen);
hexEncoder.MessageEnd();
hexEncoder.Get(pData2,dwLen*2);
And there we have it. It is also possible to add multiple blocks of data to the
encoders stream i.e.
HexEncoder hexEncoder;
hexEncoder.Put(pDataA,dwLenA);
hexEncoder.Put(pDataB,dwLenB);
hexEncoder.Put(pDataC,dwLenC);
hexEncoder.MessageEnd();
hexEncoder.Get(pData2,(dwLenA+dwLenB+dwLenC)*2);
Decoding
Decoding is equally simple.
HexDecoder hexDecoder;
hexDecoder.Put(pData,dwLen);
hexDecoder.MessageEnd();
hexDecoder.Get(pData2,dwLen/2); 2001-Jan-12 10:55pm shaun_wilde, weidai |