QuickHash Library C++ Interface

CMD2::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 message digest.

 pSrc

    [in]

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

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

 nSrcLength

    [in] Length in bytes of the memory block.

 bUpper

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

Remarks

Calculates the message digest for the memory block pointed by pSrc.

Calculates the message digest for the null-terminated string pointed by pSrc.

The digest 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 CMD2::HEXDIGESTSIZE characters.

Example

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

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

    //Calculate and retrieve the digest in hex format

    CMD2::CalculateHex( digesthex, (const unsigned char*)mydata, strlen( mydata ) );

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

 

 

Note.

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

    CMD2::CalculateHex( digesthex, (const unsigned char*)mydata, strlen( mydata ) );

can be replaced by

    CMD2::CalculateHex( digesthex, mydata );

 

CMD2 Overview   |   Class Members   |   Useful Links   |   HashCalc

 

See Also    CMD2::Calculate


 

 

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