subhashree satpathy
31st January 2018, 11:59
Decrypt the database to a plaintext database
$ sqlcipher u.db
sqlite> PRAGMA key = '234ii';
sqlite> PRAGMA cipher_use_hmac = OFF;
sqlite> ATTACH DATABASE 'plaintext.db' AS plaintext KEY '';
sqlite> SELECT sqlcipher_export('plaintext');
sqlite> DETACH DATABASE plaintext;
sqlite> .q
This is working fine, but while coming to Qt Code we are trying to execute the same queries by using QSqlQuery.
This is the code flow how we are following in Qt-4.7.4,
QSqlDatabase db1 = QSqlDatabase::addDatabase("SQLITECIPHER");
db1.setDatabaseName("Qt.db");
qDebug() << QSqlDatabase::drivers();
db1.open();
QSqlQuery qry;
qry.exec("PRAGMA key = 'test123';");
qry.exec("PRAGMA cipher_use_hmac = OFF");
qry.exec("ATTACH DATABASE 'plaintext.db' AS plaintext KEY ''; ");
qry.exec("SELECT sqlcipher_export('plaintext');");
qry.exec("DETACH DATABASE plaintext; ");
qry.exec(".q");
db1.close();
In This case qry.exec("SELECT sqlcipher_export('plaintext');"); is not executing.
Please help me to sort out this issue.
$ sqlcipher u.db
sqlite> PRAGMA key = '234ii';
sqlite> PRAGMA cipher_use_hmac = OFF;
sqlite> ATTACH DATABASE 'plaintext.db' AS plaintext KEY '';
sqlite> SELECT sqlcipher_export('plaintext');
sqlite> DETACH DATABASE plaintext;
sqlite> .q
This is working fine, but while coming to Qt Code we are trying to execute the same queries by using QSqlQuery.
This is the code flow how we are following in Qt-4.7.4,
QSqlDatabase db1 = QSqlDatabase::addDatabase("SQLITECIPHER");
db1.setDatabaseName("Qt.db");
qDebug() << QSqlDatabase::drivers();
db1.open();
QSqlQuery qry;
qry.exec("PRAGMA key = 'test123';");
qry.exec("PRAGMA cipher_use_hmac = OFF");
qry.exec("ATTACH DATABASE 'plaintext.db' AS plaintext KEY ''; ");
qry.exec("SELECT sqlcipher_export('plaintext');");
qry.exec("DETACH DATABASE plaintext; ");
qry.exec(".q");
db1.close();
In This case qry.exec("SELECT sqlcipher_export('plaintext');"); is not executing.
Please help me to sort out this issue.