// This code uses the #import directive.
// Put the following line at the beginning of your module
#import "XCEEDCRY.DLL" no_namespace named_guids
CoInitialize( NULL );
try
{
IXceedHashingPtr piHash;
piHash.CreateInstance( CLSID_XceedHashing );
piHash->License( _bstr_t( L"your license key ) );
IXceedSHAHashingMethodPtr piSHA;
piSHA.CreateInstance( CLSID_XceedSHAHashingMethod );
piSHA->PutHashSize( 256 );
piHash->HashingMethod = IXceedHashDataPtr( piSHA );
const char* pszSource = "This is the data to hash";
DWORD dwSourceSize = lstrlen( pszSource ) + 1; // Let's say we want to hash the null-char too
BYTE* pcHashValue = NULL;
short nHashValueSize = 0;
piHash->Hash( ( BYTE* )pszSource, dwSourceSize, TRUE );
piSHA->GetHashValue( &pcHashValue, &nHashValueSize );
//Do something with the HashValue...
MessageBox( NULL, "Data hashed successfully", "Hashing result", MB_OK );
CoTaskMemFree( pcHashValue );
}
catch( const _com_error& xErr )
{
char szMsg[50];
wsprintf( szMsg, "Error %08x\n", xErr.Error() );
MessageBox( NULL, szMsg, "Error", MB_OK );
}
catch( ... )
{
MessageBox( NULL, "Unknown error", "Error", MB_OK );
}
CoUninitialize();