Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[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?
Put the data into a QByteArray and use QByteArray::toHexRepresentation() to convert it to a string.
andre last edited by
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.
toHex() is what I meant. It's perfectly useful as hex is only ascii characters anyway.
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:
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@
goetz last edited by
Moved to the General forum, as it's not a tools issue.
It work thank you