Contents 

SlavaSoft FastCRC Library Online Help

Prev Page Next Page
FastCRC Library C++ Interface

CFastCRC16::Final

unsigned long Final();
 

Return value

The checksum.

Remarks

Call this member function to retrieve the checksum from the CFastCRC16 object.

After the Final method is performed, the CFastCRC16 object is initialized for new calculations, as it would be constructed again.

Example

#include <fstream>
#include <FastCRC.h>

using namespace std;
using namespace FastCRC;

const unsigned int BUFF_SIZE = 1024;

int main()
{
    fstream file( "c:\\test.txt", ios::in | ios::binary );

    if( !file )
        return 1;

    unsigned char buff[ BUFF_SIZE ];
 
    //Instantiate a CFastCRC16 object

    CFastCRC16 crcobj;

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

    while( !file.eof() )
    { 
        file.read( ( char* )buff, BUFF_SIZE );
        crcobj.Update( buff, file.gcount() );
    }

    //Do final changes and get the checksum

    unsigned long checksum = crcobj.Final();

    //Use the checksum
    //...

    file.close();
    return 0;
}

 

 

CFastCRC16 Overview   |   Class Members   |   Useful Links   |   HashCalc

 

See Also    CFastCRC16::Update, SL_FCRC_ConvertToHex16 


 

 

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