Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Moved] How to display in an editor the result of encryption
Forum Updated to NodeBB v4.3 + New Features

[Moved] How to display in an editor the result of encryption

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 3.0k 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.
  • S Offline
    S Offline
    SamFaye
    wrote on last edited by
    #1

    I'm using qca to encrypt data by doing as follows: SecureArray pubkey.encrypt result = (arg, QCA:: EME_PKCS1_OAEP);

    What I want is to display result in an editor to use the result of encryption in an application by making a copy paste into a text box

    How could it?

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      Put the data into a QByteArray and use QByteArray::toHexRepresentation() to convert it to a string.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Is that function new in 4.8? I don' t see it in the 4.7 docs. There is a toHex though, and that one can in turn be fed to QString::fromAscii to yield a valid string.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #4

          toHex() is what I meant. It's perfectly useful as hex is only ascii characters anyway.

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SamFaye
            wrote on last edited by
            #5

            I'm using this
            @
            QString rstr = QCA::arrayToHex(result.toByteArray());
            @

            But when I want I use this string in my application, when I use my secret key to decrypte this string, the decryption failed.

            I do this to construct the securrArray whitch I passe to my methode for decryption:
            @QCA::SecureArray messageCrypte(clefSaisie.toStdString().c_str())@

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Franzk
              wrote on last edited by
              #6

              Round-trip (as I would expect it):
              @QCA::SecureArray result = messageCrypte(dataToEncrypt);

              QString rstr = QString::fromAscii(result.toByteArray().toHex());
              // rstr contains hex representation of the encrypted data

              QCA::SecureArray decrypted = messageCrypte(QByteArray::fromHex(rstr.toAscii()));

              // decrypted == dataToEncrypt@

              "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #7

                Moved to the General forum, as it's not a tools issue.

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SamFaye
                  wrote on last edited by
                  #8

                  It work thank you

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved