Contents 

SlavaSoft FastCRC Library Online Help

Prev Page Next Page
FastCRC Library C++ Interface

CFastCRC32::Calculate

static unsigned long Calculate( const unsigned char* pSrc, unsigned int nSrcLength );

static unsigned long Calculate( const char* pSrc );

static int Calculate( unsigned long* pCRC, const char* pFileName );

Parameters

 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. 

 pCRC

    [out] Pointer to the variable that will receive the checksum.

pFileName

    [in] Pointer to the null-terminated string specifying the name of the file for which to calculate the checksum. 

Remarks

  • static unsigned long Calculate( const unsigned char* pSrc, unsigned int nSrcLength );

Calculates and returns the checksum for the memory block pointed by pSrc.

  • static unsigned long Calculate( const char* pSrc );

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

  • static int Calculate( unsigned long* pCRC, const char* pFileName );

Calculates the checksum for the file pointed by pFileName. The checksum is retrieved in the variable pointed by pCRC.

Return value

Zero if calculation is successful, otherwise nonzero.

Example

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

int main()
{
    char mydata[] = "Test String";
 
    //Calculate and retrieve the checksum

    unsigned long checksum = CFastCRC32::Calculate( (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

    CFastCRC32::Calculate( (const unsigned char*)mydata, strlen( mydata ) );

can be replaced by

    CFastCRC32::Calculate( mydata );

 

CFastCRC32 Overview   |   Class Members   |   Useful Links   |   HashCalc

 

See Also    SL_FCRC_ConvertToHex32 


 

 

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