User (Old forums)MemberFebruary 27, 2007 at 6:51 amPost count: 23064
I am trying to do the following :
COleException* pEx = new COleException;
// Create an instance of the XceedEncryption class
if( !xHashor.CreateDispatch( “Xceed.Hashing”, pEx ) )
if( !xSHA.CreateDispatch( “Xceed.SHAHashingMethod”, pEx ) )
xSHA.SetHashSize( 256 );
VARIANT var = xSHA.GetHashValue();
Now How do I get the Hash Value out of the Variant and into a CString ?
Imported from legacy forums. Posted by Solid (had 6841 views)User (Old forums)MemberFebruary 27, 2007 at 4:28 pmPost 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)MemberMarch 5, 2007 at 12:08 pmPost 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.
Imported from legacy forums. Posted by Solid (had 469 views)User (Old forums)MemberMarch 7, 2007 at 11:46 amPost 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)
- You must be logged in to reply to this topic.