QuickHash Library C++ Interface

CAdler32::CalculateHex

static void CalculateHex( char* pDest, const unsigned char* pSrc, unsigned int nSrcLength, bool bUpper = false );

static void CalculateHex( char* pDest, const char* pSrc, bool bUpper = false );

Parameters

 pDest

    [out] Pointer to the text buffer that will receive the checksum.

 pSrc

    [in]

    In the first case - pointer to the continuous memory block for which to calculate the checksum.

    In the second case - pointer to the null-terminated string for which to calculate the checksum.

 nSrcLength

    [in] Length in bytes of the memory block.

 bUpper

    [in] Uppercase flag. If bUpper is false, the received checksum represents a lowercase string, otherwise it represents an uppercase string. 

Remarks

Calculates the checksum for the memory block pointed by pSrc.

Calculates the checksum for the null-terminated string pointed by pSrc.

The checksum is retrieved as a null-terminated hexadecimal string in the text buffer pointed by pDest. The size of the text buffer pointed by pDest must be at least CAdler32::HEXDIGESTSIZE characters.

Example

#include <string.h>
#include <QuickHash.h>
using namespace QuickHash;

int main()
{
    char mydata[] = "Test String";
    char checksumhex[ CAdler32::HEXDIGESTSIZE ]; //0 terminated

    //Calculate and retrieve the checksum in hex format

    CAdler32::CalculateHex( checksumhex, (const unsigned char*)mydata, strlen( mydata ) );

    //Use the checksum
    //...
    return 0;
}

 

 

Note.

In the above example mydata is a null-terminated string. Therefore, the call

    CAdler32::CalculateHex( checksumhex, (const unsigned char*)mydata, strlen( mydata ) );

can be replaced by

    CAdler32::CalculateHex( checksumhex, mydata );

 

CAdler32 Overview   |   Class Members   |   Useful Links   |   HashCalc

 

See Also    CAdler32::Calculate


 

 

Send Feedback to SlavaSoft Inc. Tell a friend about QuickHash Library