QuickHash Library API


void SL_HASHCALL SL_ADLER32_FinalHex( void* pContext, void* pDest, int bUpper );



    [in/out] Pointer to the context.


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


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


Call this function to retrieve the checksum from the context pointed by pContext. The checksum 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 SLC_ADLER32_HEXDIGESTSIZE characters.

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


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

#define BUFF_SIZE  1024

int main()
    FILE* file;
    unsigned char buff[ BUFF_SIZE ];
    unsigned char context[ SLC_ADLER32_CONTEXTSIZE ];
    char checksumhex[ SLC_ADLER32_HEXDIGESTSIZE ]; /*0 terminated*/

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

    if( file == NULL )
        return 1;

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

    SL_ADLER32_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_ADLER32_Update( context, buff, nCount );

    /*****Do final changes and get the checksum in hex format*******************/

    SL_ADLER32_FinalHex( context, checksumhex, 0 );

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

    fclose( file );

    return 0;


ADLER32 API Overview   |   ADLER32 API Functions   |   Useful Links   |   HashCalc

See Also    SL_ADLER32_Final, SL_ADLER32_Update, SL_ADLER32_UpdateStr, SL_ADLER32_Init



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