Home Forums ActiveX components Xceed Encryption for ActiveX Encrpt & Binary Encode – ToString method problem

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #42978 |


    I am testing XCeed encrypt to encrypt data to be saved to a number of MS Access databases from C++ porgrams.   With the help of Andre at Xceed I have been using the XCeed examples from both the encrypt and Binary encode controls to prove the princiipal but have run into a brick wall with the ToString function.  No matter what I do when I call the ToString function I get error 80004003 back.  I belive this has something to do with the parameters being invalid but have been unable to pin-point the problem  Below is a sinppit of code which I hope will lead somebody to see where I am going wrong….

     IXceedEncryptionPtr piEnc;
     piEnc.CreateInstance( CLSID_XceedEncryption );
     piEnc->License( _bstr_t( L”your license key” ) ); 
     IXceedRijndaelEncryptionMethodPtr piRijndael;
     piRijndael.CreateInstance( CLSID_XceedRijndaelEncryptionMethod );
     piRijndael->SetSecretKeyFromPassPhrase( “This is a weak pass phrase!”, 128 );
     piEnc-> EncryptionMethod = IXceedEncryptDataPtr( piRijndael );
     const char* pszSource = “This is the data to encrypt”;

     DWORD dwSourceSize = lstrlen( pszSource ) + 1;
     BYTE* pcEncrypted = NULL;
     DWORD dwEncryptedSize = 0;

     piEnc->Encrypt( ( BYTE* )pszSource, dwSourceSize, TRUE, &pcEncrypted, &dwEncryptedSize );   //encrpt it

     //now do the binary encoding
     IXceedBinaryEncodingPtr piBinEncoder;
     piBinEncoder.CreateInstance( CLSID_XceedBinaryEncoding );
     piBinEncoder->License( _bstr_t( L”your license key” ) );
     IXceedUUEncodingFormatPtr piUUEncode;
     piUUEncode.CreateInstance( CLSID_XceedUUEncodingFormat );
     piUUEncode->IncludeHeaderFooter = FALSE; 
     piBinEncoder->EncodingFormat = IXceedEncodeDataPtr( piUUEncode ); 

     char* pcSource = (char*)pcEncrypted;
     BYTE* pcEncoded = NULL;
     DWORD dwEncodedSize; 

     //binary encode the output from encrypt
     piBinEncoder->Encode(( BYTE* )pcSource, lstrlen( pcSource ), TRUE, &pcEncoded, &dwEncodedSize );

     //now use the tostring function
     BSTR* pszOutput = NULL;
     HRESULT vTest;
     vTest = piBinEncoder->ToString(( BYTE* ) pcEncoded, (DWORD)dwEncodedSize, pszOutput);  //fails at this point with 80004003 error

    Many Thanks for your help

    Imported from legacy forums. Posted by David (had 4893 views)

    User (Old forums)
    Post count: 23064

    Do not use the ToString() method.  It was created to help customers using languages that can not handle byte arrays (FoxPro).   You can use the byte array directly (some methods in C++ will permit that) or convert it to a string via a custom implementation like in the following post :


    You can also look at our MemoryEncrypt sample, more specifically the BinaryToHex() method, to see an example on how to encrypt and convert the resulting byte array to a string.

    Under Vista :

    C:\Xceed Component Samples\Xceed Encryption Library 1.1\Samples\Visual C++ 6-7\MemoryEncrypt

    Under XP :

    C:\Program Files\Xceed Components\Xceed Encryption Library 1.1\Samples\Visual C++ 6-7\MemoryEncrypt


    Imported from legacy forums. Posted by André (had 6703 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.