View Full Version : Encryption with Qt

1st May 2013, 17:15
I want to encrypt text with Qt and I use the QCA. I followed this tutorial (http://www.essentialunix.org/index.php?option=com_content&view=article&id=48:qcatutorial&catid=34:qttutorials&Itemid=53) and successfully.

But when I only use for decrypt, the process is failed. this is my code

QCA::Cipher cipher = QCA::Cipher(QString("aes128"), QCA::Cipher::CBC,
QCA::Cipher::DefaultPadding, QCA::Decode,
key, iv);

QString s="0c7d98f0421591e1bec5b125170453d7";
QCA::SecureArray encryptedData = s.toAscii();
QCA::SecureArray decryptedData = cipher.process(encryptedData);
if (!cipher.ok()) {
qDebug() << "Decryption failed !";
qDebug() << QString(decryptedData.data());

What's wrong with my code?

* Btw, I can decrypt everything what I encrypt in QCA with php-mcrypt ?

1st May 2013, 17:48
You're decrypting textual representation (lines #5-6) of your ciphertext.