Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Unable to open manually-encrypted SQLite database with QtCipherSqlitePlugin and vice versa
Forum Updated to NodeBB v4.3 + New Features

Unable to open manually-encrypted SQLite database with QtCipherSqlitePlugin and vice versa

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
2 Posts 2 Posters 870 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SupIQ
    wrote on 7 Sept 2018, 15:04 last edited by
    #1

    I have manually created a SQLite database (named "localDB.db") and protected it with a password, by using DB browser. If I am not mistaken, DB browser uses SQLCipher (with a default page size of 1024), for encrypting a database.
    However, if I try to open the database with the QT plugin called QtCipherSqlitePlugin (see following code), I always get the error that "the password is invalid or cipher does not match", although I obviously provide the correct password and have set the cipher as "sqlcipher".

    #include <QCoreApplication>
    #include <QDebug>
    #include <QDir>
    #include <QSqlError>
    #include <QtSql/QSqlDatabase>
    
    #ifdef Q_OS_IOS
    
    #include <QtPlugin>
    
    Q_IMPORT_PLUGIN(SqliteCipherDriverPlugin)
    
    #endif
    
    #define CONNECTION_FAILED -1
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        qDebug() << QSqlDatabase::drivers();
    
        QString dir = QCoreApplication::applicationDirPath();
        QString db_file_path = dir + "/Data/localDB.db";
        qDebug() << "DB file path is:" << db_file_path;
    
        QSqlDatabase db = QSqlDatabase::addDatabase("SQLITECIPHER");
        db.setDatabaseName(db_file_path);
        db.setPassword("test");
        db.setConnectOptions("QSQLITE_USE_CIPHER=sqlcipher");
        db.open();
    
        if (!db.isOpen())
        {
            qDebug() << "Connection failed: " << db.lastError().driverText();
            exit(CONNECTION_FAILED);
        }
    
        return 0;
    }
    

    The same happens for the inverse process: if I encrypt a database by using this plugin, then I am unable to manually open the database with DB Browser or other similar programs, because it does not accept the password.

    How can I solve this problem? I need to access an encrypted SQLite database through both my software and a third-party application like DB browser. Thanks in advance.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 7 Sept 2018, 21:15 last edited by
      #2

      Hi and welcome to devnet,

      You should rather contact the authors of both project. They'll likely have better knowledge about that part.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      1/2

      7 Sept 2018, 15:04

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved