August 17, 2011

SamFaye SamFaye
Lab Rat
59 posts

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

 

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?

7 replies

August 17, 2011

Franzk Franzk
Lab Rat
830 posts

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

 Signature 

“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

August 17, 2011

Andre Andre
Area 51 Engineer
6031 posts

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.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

August 17, 2011

Franzk Franzk
Lab Rat
830 posts

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

 Signature 

“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

August 17, 2011

SamFaye SamFaye
Lab Rat
59 posts

I’m using this

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

  1. QCA::SecureArray messageCrypte(clefSaisie.toStdString().c_str())

August 17, 2011

Franzk Franzk
Lab Rat
830 posts

Round-trip (as I would expect it):

  1. QCA::SecureArray result = messageCrypte(dataToEncrypt);
  2.  
  3. QString rstr = QString::fromAscii(result.toByteArray().toHex());
  4. // rstr contains hex representation of the encrypted data
  5.  
  6. QCA::SecureArray decrypted = messageCrypte(QByteArray::fromHex(rstr.toAscii()));
  7.  
  8. // decrypted == dataToEncrypt

 Signature 

“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

August 17, 2011

Volker Volker
Robot Herder
5428 posts

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

August 17, 2011

SamFaye SamFaye
Lab Rat
59 posts

It work thank you

 
  ‹‹ Setting global variable in main() [Solved]      Defining buttons in OpenGL-window ››

You must log in to post a reply. Not a member yet? Register here!