I want to encrypt text with Qt and I use the QCA. I followed this tutorial 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 !";
return;
}
qDebug
() <<
QString(decryptedData.
data());
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 !";
return;
}
qDebug() << QString(decryptedData.data());
To copy to clipboard, switch view to plain text mode
What's wrong with my code?
* Btw, I can decrypt everything what I encrypt in QCA with php-mcrypt ?
Bookmarks