QuickHash Library API

SL_CRC16_Final

void SL_HASHCALL SL_CRC16_Final( void* pContext, void* pDest );
 

Parameters

 pContext

    [in/out] Pointer to the context.

 pDest

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

Remarks

Call this function to retrieve the checksum from the context pointed by pContext. The checksum is retrieved in the memory buffer pointed by pDest. The size of the memory buffer pointed by pDest must be at least SLC_CRC16_DIGESTSIZE bytes.

After the SL_CRC16_Final function is performed, the context is initialized for new calculations, as it would be called SL_CRC16_Init again.

Example

#include <stdio.h>
#include <QuickHash.h>

#define BUFF_SIZE  1024

int main()
{
    FILE* file;
    unsigned char buff[ BUFF_SIZE ];
    unsigned char context[ SLC_CRC16_CONTEXTSIZE ];
    unsigned char checksum[ SLC_CRC16_DIGESTSIZE ];

    file = fopen( "c:\\test.txt", "rb" );

    if( file == NULL )
        return 1;

    /*****Initialize the context before calling Update, Final, or FinalHex****/

    SL_CRC16_Init( context );

    /*****Calculate the checksum by calling Update for each block of the file***/

    while( !feof( file ) )
    {
        unsigned int nCount = fread( buff, sizeof( char ), BUFF_SIZE, file );
        SL_CRC16_Update( context, buff, nCount );
    }

    /*****Do final changes and get the checksum*********************************/

    SL_CRC16_Final( context, checksum );

    /*****Use the checksum******************************************************/
    /*...*/

    fclose( file );

    return 0;
}

 

 

CRC16 API Overview   |   CRC16 Functions   |   Useful Links   |   HashCalc

 

See Also    SL_CRC16_FinalHex, SL_CRC16_Update, SL_CRC16_UpdateStr, SL_CRC16_Init


 

 

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