Contents 

QuickHash Library
QuickHash Library Overview
QuickHash Library Applications
QuickHash Library Installation
Register QuickHash Library
MD2
CMD2 ( C++ Interface )
CMD2 class members
MD2 API ( QuickHash API )
MD2 API Functions
MD2 ( QuickHash Type Library )
MD4
CMD4 ( C++ Interface )
CMD4 class members
MD4 API ( QuickHash API )
MD4 API Functions
MD4 ( QuickHash Type Library )
MD5
CMD5 ( C++ Interface )
CMD5 class members
MD5 API ( QuickHash API )
MD5 API Functions
MD5 ( QuickHash Type Library )
SHA-1
CSHA1 ( C++ Interface )
CSHA1 class members
SHA1 API ( QuickHash API )
SHA1 API Functions
SHA1 ( QuickHash Type Library )
SHA-2 (256)
CSHA256 ( C++ Interface )
CSHA256 class members
SHA256 API ( QuickHash API )
SHA256 API Functions
SHA256 ( QuickHash Type Library )
SHA-2 (384)
CSHA384 ( C++ Interface )
CSHA384 class members
SHA384 API ( QuickHash API )
SHA384 API Functions
SHA384 ( QuickHash Type Library )
SHA-2 (512)
CSHA512 ( C++ Interface )
CSHA512 class members
SHA512 API ( QuickHash API )
SHA512 API Functions
SHA512 ( QuickHash Type Library )
RIPEMD-128
CRIPEMD128 ( C++ Interface )
CRIPEMD128 ( C++ Interface )
RIPEMD128 API ( QuickHash API )
RIPEMD128 API Functions
RIPEMD128 ( QuickHash Type Library )
RIPEMD-160
CRIPEMD160 ( C++ Interface )
CRIPEMD160 ( C++ Interface )
RIPEMD160 API ( QuickHash API )
RIPEMD160 API Functions
RIPEMD160 ( QuickHash Type Library )
RIPEMD-256
CRIPEMD256 ( C++ Interface )
CRIPEMD256 ( C++ Interface )
RIPEMD256 API ( QuickHash API )
RIPEMD256 API Functions
RIPEMD256 ( QuickHash Type Library )
RIPEMD-320
CRIPEMD320 ( C++ Interface )
CRIPEMD320 ( C++ Interface )
RIPEMD320 API ( QuickHash API )
RIPEMD320 API Functions
RIPEMD320 ( QuickHash Type Library )
PANAMA
CPanama ( C++ Interface )
CPanama class members
PANAMA API ( QuickHash API )
PANAMA API Functions
PANAMA ( QuickHash Type Library )
TIGER
CTiger
CTiger class members
TIGER API ( QuickHash API )
TIGER API Functions
TIGER ( QuickHash Type Library )
CRC16
CCRC16 ( C++ Interface )
CCRC16 class members
CRC16 API ( QuickHash API )
CRC16 API Functions
CRC16 ( QuickHash Type Library )
CRC16C
CCRC16C ( C++ Interface )
CCRC16C class members
CRC16C API ( QuickHash API )
CRC16C API Functions
CRC16C ( QuickHash Type Library )
CRC32
CCRC32 ( C++ Interface )
CCRC32 class members
CRC32 API ( QuickHash API )
CRC32 API Functions
CRC32 ( QuickHash Type Library )
ADLER32
CAdler32 ( C++ Interface )
CAdler32 class members
ADLER32 API ( QuickHash API )
ADLER32 API Functions
ADLER32 ( QuickHash Type Library )
HMAC
CHMAC ( C++ Interface )
CHMAC class members
HMAC API ( QuickHash API )
HMAC API Functions
HMAC ( QuickHash Type Library )
QuickHash Type Library
Type Library Overview
Type Library Functions
Type Library Constants
Type Library Types
Type Library Error Codes
QuickHash Library Run-Time Dynamic Linking
Function Indicies in QuickHash.dll
License Agreement
Samples

SlavaSoft QuickHash Library Online Help

Prev Page Next Page
QuickHash Library API

QuickHash Library Run-Time Dynamic Linking

In order to perform run-time dynamic linking to QuickHash.dll, follow these steps:

  1. Call Windows API LoadLibrary function passing the name of the library ( "QuickHash.dll" ). The function returns the handle to loaded DLL.
  2. Call Windows API GetProcAddress function passing the handle received in Step 1 and the index of the function you want to use.  GetProcAddress returns the pointer to the specified function. The corresponding indices for each function from QuickHash.dll are listed here.
  3. Repeat Step 2 for all functions you need to use.
  4. Call the function(s) through the pointer(s) received in Step 2.
  5. At the end call Windows API FreeLibrary function passing the handle received in Step 1.

Example

#include <stdio.h>
#include <string.h>
#include <windows.h>

/* All function indices in QuickHash.dll can be found in:*/
/* QuickHash Library Help (QuickHash Library Run-Time Dynamic Linking page) */
#define MD5_INIT_INDEX          51
#define MD5_UPDATE_INDEX        52
#define MD5_FINAL_INDEX         53
#define MD5_FINALHEX_INDEX      55
#define MD5_CALCULATE_INDEX     54
#define MD5_CALCULATEHEX_INDEX  56

/* These constants can be found in QuickHash.h */
#define MD5_DIGESTSIZE          16
#define MD5_HEXDIGESTSIZE       ( MD5_DIGESTSIZE * 2 + 1 ) 
#define MD5_CONTEXTSIZE         88 

/* Declare pointer types for each function you need to use */
typedef void ( _stdcall *PINIT )( void* );
typedef void ( _stdcall *PUPDATE )( void*, const void*, unsigned int );
typedef void ( _stdcall *PFINAL )( void*, void* );
typedef void ( _stdcall *PFINALHEX )( void*, void*, int );
typedef void ( _stdcall *PCALCULATE )( void*, const void*, unsigned int );
typedef void ( _stdcall *PCALCULATEHEX )( void*, const void*, unsigned int, int );

void ConvertToHex( char* dest, const unsigned char* src, unsigned int count );

int main()
{
    PINIT           pInit;
    PUPDATE         pUpdate;
    PFINAL          pFinal;
    PFINALHEX       pFinalHex;
    PCALCULATE      pCalculate;
    PCALCULATEHEX   pCalculateHex;

    char buff[ 256 ];

    unsigned char digest[ MD5_DIGESTSIZE ];
    char          digesthex[ MD5_HEXDIGESTSIZE ]; /*0 terminated*/

    unsigned char context[ MD5_CONTEXTSIZE ];

    /*****Load QuickHash.dll*************/
    HMODULE hModule = LoadLibrary( "QuickHash.dll" );
    if( !hModule )
    {
        printf( "Could not load QuickHash.dll library" );
        return 1;
    }

    /*****Get all function addresses*****/
    pInit         = (PINIT)GetProcAddress( hModule, (LPCSTR)MD5_INIT_INDEX );
    pUpdate       = (PUPDATE)GetProcAddress( hModule, (LPCSTR)MD5_UPDATE_INDEX );
    pFinal        = (PFINAL)GetProcAddress( hModule, (LPCSTR)MD5_FINAL_INDEX );
    pFinalHex     = (PFINALHEX)GetProcAddress( hModule, (LPCSTR)MD5_FINALHEX_INDEX );
    pCalculate    = (PCALCULATE)GetProcAddress( hModule, (LPCSTR)MD5_CALCULATE_INDEX );
    pCalculateHex = (PCALCULATEHEX)GetProcAddress( hModule, (LPCSTR)MD5_CALCULATEHEX_INDEX );

    do
    {
        /*****Get the string from the user****************************************/

        printf( "\nEnter a string: " );
        gets( buff );

        printf( "\nDigest for \"%s\":", buff );

        /*****Calculate the digest using CalculateHex*****************************/

        printf( "\nCalculated using CalculateHex:        " );
        
        ( *pCalculateHex )( digesthex, buff, strlen( buff ), 0 );

        printf( "%s", digesthex );

        /*****Calculate the digest using Calculate********************************/

        printf( "\nCalculated using Calculate:           " );

        ( *pCalculate )( digest, buff, strlen( buff ) );

        ConvertToHex( digesthex, digest, MD5_DIGESTSIZE );

        printf( "%s", digesthex );

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

        ( *pInit )( context );

        /*****Calculate the digest using Update and FinalHex**********************/

        printf( "\nCalculated using Update and FinalHex: " );

        ( *pUpdate )( context, buff, strlen( buff ) );
        ( *pFinalHex )( context, digesthex, 0 ); /* FinalHex reinitializes the context for the next use */

        printf( "%s", digesthex );

        /*****Calculate the digest using Update and Final*************************/

        printf( "\nCalculated using Update and Final:    " );

        ( *pUpdate )( context, buff, strlen( buff ) );
        ( *pFinal )( context, digest ); /* Final reinitializes the context for the next use */

        ConvertToHex( digesthex, digest, MD5_DIGESTSIZE );

        printf( "%s", digesthex );

        /*****Continue?***********************************************************/

        printf( "\nContinue (Y/N)?" );
        gets( buff );

    }while( *buff == 'y' || *buff == 'Y' );

    FreeLibrary( hModule );

    return 0;
}

void ConvertToHex( char* dest, const unsigned char* src, unsigned int count )
{
    static char hex[ 16 ] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };

    unsigned int i = 0;

    for( ; i < count; ++i )
    {
        *dest++ = hex[ *src / 16 ];
        *dest++ = hex[ *src++ % 16 ];
    }

    *dest = '\0';
}

 

 

QuickHash Library Overview   |   MD5 API Overview   |   Useful Links   |   HashCalc

 

See Also    Function Indices in QuickHash.dll


 

 

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