[SOLVED] possible to pass in a string as UNICODE?
-
hey, i'm working with a function which creates a base 64 hash of a string which i enter, and then another function which verifies if the hashed data is the same as the original string. (yup its CAPICOM again:mad:). the problem is that the sign and verify functions return _bstr_t data types and accepts UNICODE style data only. so im signing data using the sign function (which wants and returns _bstr_t type string) and then i verify it (again returns a bstr_t type) but it fails at verifying. i googled it a lot and someplaces say its because CAPICOM only works with UNICODE data. so my question: how do i pass in the bstr_t string as a UNICODE? edit: I guess I misinterpreted the displayed value of 0...
-
hey, i'm working with a function which creates a base 64 hash of a string which i enter, and then another function which verifies if the hashed data is the same as the original string. (yup its CAPICOM again:mad:). the problem is that the sign and verify functions return _bstr_t data types and accepts UNICODE style data only. so im signing data using the sign function (which wants and returns _bstr_t type string) and then i verify it (again returns a bstr_t type) but it fails at verifying. i googled it a lot and someplaces say its because CAPICOM only works with UNICODE data. so my question: how do i pass in the bstr_t string as a UNICODE? edit: I guess I misinterpreted the displayed value of 0...
Well,
bstr_t
encapsulatesBSTR
strings, that, roughly speaking areOLECHAR *
, finallyOLECHAR
areWCHAR
, i.e. wide char. The point is:bstr_t
represent aUNICODE
string so, what is your problem? Could you please post the relevant code? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Well,
bstr_t
encapsulatesBSTR
strings, that, roughly speaking areOLECHAR *
, finallyOLECHAR
areWCHAR
, i.e. wide char. The point is:bstr_t
represent aUNICODE
string so, what is your problem? Could you please post the relevant code? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]lol u asked for it :(( i don't know how familiar you are with the CAPICOM functions but this is bascially the code and below is what i want the outcome to be: <pre> CAPICOM::ISignerPtr signer(__uuidof(Signer)); CAPICOM::ISignedDataPtr sigData(__uuidof(SignedData)); sigData->Content = "Data to Sign"; _bstr_t sigStr = sigData->Sign(signer,true,CAPICOM_ENCODE_BASE64); cout<<"\n\nVerified String: "<<sigData->Verify(sigStr, true, CAPICOM_VERIFY_SIGNATURE_ONLY)<<endl; </pre> This code sets the content to be signed to "Data to Sign", and creates a hash with the signer's private key(can be displayed by cout<<sigStr;). in Verify function it should (it does in java) display the decrypted string (i.e "Data to Sign" on the console, whereas I'm getting a 0 on my end X| ). I read the article http://www.codeproject.com/KB/security/CapicomUTF8.aspx and it mentioned that fact that it wants unicode. uh... hope that helps you figure out what i'm trying to say... :sigh:
-
lol u asked for it :(( i don't know how familiar you are with the CAPICOM functions but this is bascially the code and below is what i want the outcome to be: <pre> CAPICOM::ISignerPtr signer(__uuidof(Signer)); CAPICOM::ISignedDataPtr sigData(__uuidof(SignedData)); sigData->Content = "Data to Sign"; _bstr_t sigStr = sigData->Sign(signer,true,CAPICOM_ENCODE_BASE64); cout<<"\n\nVerified String: "<<sigData->Verify(sigStr, true, CAPICOM_VERIFY_SIGNATURE_ONLY)<<endl; </pre> This code sets the content to be signed to "Data to Sign", and creates a hash with the signer's private key(can be displayed by cout<<sigStr;). in Verify function it should (it does in java) display the decrypted string (i.e "Data to Sign" on the console, whereas I'm getting a 0 on my end X| ). I read the article http://www.codeproject.com/KB/security/CapicomUTF8.aspx and it mentioned that fact that it wants unicode. uh... hope that helps you figure out what i'm trying to say... :sigh:
sadman89 wrote:
sigData->Content = "Data to Sign";
Why don't you use
sigData->Content = bstr_t(L"Data to Sign");
?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
sadman89 wrote:
sigData->Content = "Data to Sign";
Why don't you use
sigData->Content = bstr_t(L"Data to Sign");
?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]ok i tried that (and _bstr_t(..)) still the verification is displaying a 0 :confused: i guess the cast(?) is fundamentally correct, but its still not giving me the expected output. I also looked at the excellent http://www.codeproject.com/KB/string/cppstringguide2.aspx for some new ideas but no luck :( darn this COM and the lack of help from Microsoft
modified on Monday, June 22, 2009 4:01 AM