Home Forums ActiveX components Xceed Encryption for ActiveX CString from GetHashValue

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #42945 |

    Hi,

    I am trying to do the following :

    COleException* pEx = new COleException;
    DXceedHashing xHashor;

    try
    {
    // Create an instance of the XceedEncryption class
    if( !xHashor.CreateDispatch( “Xceed.Hashing”, pEx ) )
    throw pEx;
    DXceedSHAHashingMethod xSHA;
    if( !xSHA.CreateDispatch( “Xceed.SHAHashingMethod”, pEx ) )
    throw pEx;
    xSHA.SetHashSize( 256 );
    xHashor.SetRefHashingMethod(xSHA.m_lpDispatch);
    xHashor.Hash(COleVariant(testSerial), TRUE);

    VARIANT var = xSHA.GetHashValue();

    Now How do I get the Hash Value out of the Variant and into a CString ?

    Thanks

    Imported from legacy forums. Posted by Solid (had 6841 views)

    User (Old forums)
    Member
    Post count: 23064

    The hash value is a raw byte array, not a string. You cannot directly put it in a CString, you have to encode it first. For that, you can use any binary encoder (for instance, Xceed Binary Encoding Library). In the MFC MemoryEncrypt sample installed with the product, we do something similar with the result of an encryption. If you look at the CMemoryEncryptDlg::OnCmdEncrypt() method, you’ll see that we use a local function to encode in Hexadecimal (BinaryToHex) and put the result in a CString.

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

    User (Old forums)
    Member
    Post count: 23064

    Value from Hash sample in c++ and VB sample (Hasher) is different for same value of text and same options

    for a value of “12345123451234512345” in test.txt, hash /m=SHA /s=256 test.txt test1.txt the result in test1.txt is “BD897C7CF527137FE1CC97C1866FA6C6962DCE6D9D74B405D754DC76A66B7FF7”

    where as for the same settings and input in Hasher the output is “081115DF5D291465362F17C4B7B182DA6AAA6D8147A0FEC1ACA8435EEC404612”

    when using mhash_sha256, hex2bin of the hash is also “081115DF5D291465362F17C4B7B182DA6AAA6D8147A0FEC1ACA8435EEC404612” the same as that for hasher.

    So what is the cause for this ? Is there some bug in the BinaryToHex function ?
    Please reply ASAP.

    Regards
    Singh

    Imported from legacy forums. Posted by Solid (had 469 views)

    User (Old forums)
    Member
    Post count: 23064

    The two strings are very different. In C++, the hash input is an ASCII string, whereas in VB it is a Unicode string with, in this case, a binary zero adjacent to each character.

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

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