|
FastCRC Library |
C++ Interface |
|
CFastCRC16C::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
Calculates and returns the checksum for the memory block
pointed by pSrc.
Calculates and returns the checksum for the
null-terminated string pointed by pSrc.
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 = CFastCRC16C::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
CFastCRC16C::Calculate(
(const unsigned char*)mydata, strlen(
mydata ) );
can be replaced by
CFastCRC16C::Calculate( mydata );
CFastCRC16C Overview
| Class Members
|
Useful Links | HashCalc
See Also
SL_FCRC_ConvertToHex16
|