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. HexEncoder class to CString

HexEncoder class to CString

Scheduled Pinned Locked Moved C / C++ / MFC
htmlcomquestion
7 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
    User 2070738
    wrote on last edited by
    #1

    Im using boZoi library to implement Elliptic curve cryptography to my VC project.The functions output r in the format of hexadecimal and OCTETSTR(octant string) now if i want to show the output in the edit box control of a dialog box...???. ECDSA sig; HexEncoder hex(sig); CEdit* poEdit = static_cast(GetDlgItem(IDC_EDIT3)); poEdit->SetWindowText(hex); HexEncoder is a class which converts to hexadecimal format & i want to convert it converted to CString or LPCTSTR...How i do that? borZoi can be found at: http://dragongate-technologies.com/products.html[^]

    J 1 Reply Last reply
    0
    • U User 2070738

      Im using boZoi library to implement Elliptic curve cryptography to my VC project.The functions output r in the format of hexadecimal and OCTETSTR(octant string) now if i want to show the output in the edit box control of a dialog box...???. ECDSA sig; HexEncoder hex(sig); CEdit* poEdit = static_cast(GetDlgItem(IDC_EDIT3)); poEdit->SetWindowText(hex); HexEncoder is a class which converts to hexadecimal format & i want to convert it converted to CString or LPCTSTR...How i do that? borZoi can be found at: http://dragongate-technologies.com/products.html[^]

      J Offline
      J Offline
      Jose Lamas Rios
      wrote on last edited by
      #2

      titi@yahoo.com wrote: HexEncoder is a class which converts to hexadecimal format & i want to convert it converted to CString or LPCTSTR...How i do that? You should be able to do it the same way I told you[^] when you asked this same question[^] before. Have you tried it? -- jlr http://jlamas.blogspot.com/[^]

      U 2 Replies Last reply
      0
      • J Jose Lamas Rios

        titi@yahoo.com wrote: HexEncoder is a class which converts to hexadecimal format & i want to convert it converted to CString or LPCTSTR...How i do that? You should be able to do it the same way I told you[^] when you asked this same question[^] before. Have you tried it? -- jlr http://jlamas.blogspot.com/[^]

        U Offline
        U Offline
        User 2070738
        wrote on last edited by
        #3

        Yup it worked fine...thanx.But that converts Octant string to Hex String....here i want to convert Hexadecimal to char* or CString to show in edit box....I dont know if the same method can be applied here?

        U 1 Reply Last reply
        0
        • U User 2070738

          Yup it worked fine...thanx.But that converts Octant string to Hex String....here i want to convert Hexadecimal to char* or CString to show in edit box....I dont know if the same method can be applied here?

          U Offline
          U Offline
          User 2070738
          wrote on last edited by
          #4

          OK as u suggested i used ostringstream to store hex vaue as a string and then convert it into a CString form to show in the edit control of dialog box.It gives no error but at the time of execution of this code "illegal operation error" message box is displayed.Where Im doing wrong? std::string s(""); ECDSA sig1(sk, OS2IP(hash)); // generate the signature DER der_str (sig1); //DER class function HexEncoder hex_str(der_str); //Hexencoder class function std::ostringstream str; str<(GetDlgItem(IDC_EDIT3)); poEdit->SetWindowText(cs);

          1 Reply Last reply
          0
          • J Jose Lamas Rios

            titi@yahoo.com wrote: HexEncoder is a class which converts to hexadecimal format & i want to convert it converted to CString or LPCTSTR...How i do that? You should be able to do it the same way I told you[^] when you asked this same question[^] before. Have you tried it? -- jlr http://jlamas.blogspot.com/[^]

            U Offline
            U Offline
            User 2070738
            wrote on last edited by
            #5

            OK as u suggested i used ostringstream to store hex vaue as a string and then convert it into a CString form to show in the edit control of dialog box.It gives no error but at the time of execution of this code "illegal operation error" message box is displayed.Where Im doing wrong? std::string s(""); ECDSA sig1(sk, OS2IP(hash)); // generate the signature DER der_str (sig1); //DER class function HexEncoder hex_str(der_str); //Hexencoder class function std::ostringstream str; str<SetWindowText(cs); Hope ull reply soon.

            J 1 Reply Last reply
            0
            • U User 2070738

              OK as u suggested i used ostringstream to store hex vaue as a string and then convert it into a CString form to show in the edit control of dialog box.It gives no error but at the time of execution of this code "illegal operation error" message box is displayed.Where Im doing wrong? std::string s(""); ECDSA sig1(sk, OS2IP(hash)); // generate the signature DER der_str (sig1); //DER class function HexEncoder hex_str(der_str); //Hexencoder class function std::ostringstream str; str<SetWindowText(cs); Hope ull reply soon.

              J Offline
              J Offline
              Jose Lamas Rios
              wrote on last edited by
              #6

              titi@yahoo.com wrote: It gives no error but at the time of execution of this code "illegal operation error" message box is displayed.Where Im doing wrong? Hard to tell without knowing at what point in the code you get that error. In any case, if you looked at the DER declaration in borzoi.h, you'd note DER objects hold their data in an OCTETSTR public member named v, and as I already shown you how to code an OctetStrToHexString, you'd realize you can simply use OctetStrToHexString passing der_str.v.

              ECDSA sig1(sk, OS2IP(hash)); // generate the signature
                DER der_str (sig1); //DER class function
               
                CWnd* pWnd = GetDlgItem(IDC_EDIT3);
                if (pWnd)
                {
                CString sDer;
                OctetStrToHexString(der_str.v, sDer);
                pWnd->SetWindowText(sDer);
                }

              -- jlr http://jlamas.blogspot.com/[^]

              U 1 Reply Last reply
              0
              • J Jose Lamas Rios

                titi@yahoo.com wrote: It gives no error but at the time of execution of this code "illegal operation error" message box is displayed.Where Im doing wrong? Hard to tell without knowing at what point in the code you get that error. In any case, if you looked at the DER declaration in borzoi.h, you'd note DER objects hold their data in an OCTETSTR public member named v, and as I already shown you how to code an OctetStrToHexString, you'd realize you can simply use OctetStrToHexString passing der_str.v.

                ECDSA sig1(sk, OS2IP(hash)); // generate the signature
                  DER der_str (sig1); //DER class function
                 
                  CWnd* pWnd = GetDlgItem(IDC_EDIT3);
                  if (pWnd)
                  {
                  CString sDer;
                  OctetStrToHexString(der_str.v, sDer);
                  pWnd->SetWindowText(sDer);
                  }

                -- jlr http://jlamas.blogspot.com/[^]

                U Offline
                U Offline
                User 2070738
                wrote on last edited by
                #7

                Thnx for (late) reply but ive done it and through the same method as u told. Since Im stuck in cryptography stuff nad Im using CryptoAPI Ive some data of type BYTE* (PUBLICKEYBLOB)I want to write it in a file then send it across the network and then read from file and use that public key.SIGH!!!! now to write it in the file i covert BYTE* to CHAR* and then inverse to read ...but to dont get the same value back. Do u have any better idea to do this?? Thanx again for ur help.

                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