Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. [SOLVED] possible to pass in a string as UNICODE?

[SOLVED] possible to pass in a string as UNICODE?

Scheduled Pinned Locked Moved C / C++ / MFC
questioncryptographyhelp
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    UserNameless
    wrote on last edited by
    #1

    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...

    C 1 Reply Last reply
    0
    • U UserNameless

      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...

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      Well, bstr_t encapsulates BSTR strings, that, roughly speaking are OLECHAR *, finally OLECHAR are WCHAR, i.e. wide char. The point is: bstr_t represent a UNICODE 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]

      U 1 Reply Last reply
      0
      • C CPallini

        Well, bstr_t encapsulates BSTR strings, that, roughly speaking are OLECHAR *, finally OLECHAR are WCHAR, i.e. wide char. The point is: bstr_t represent a UNICODE 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]

        U Offline
        U Offline
        UserNameless
        wrote on last edited by
        #3

        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:

        C 1 Reply Last reply
        0
        • U UserNameless

          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:

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          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]

          U 1 Reply Last reply
          0
          • C CPallini

            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]

            U Offline
            U Offline
            UserNameless
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups