Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. SQLite Encryption Extension - PRAGMA activate_extensions= not working
Forum Update on Monday, May 27th 2025

SQLite Encryption Extension - PRAGMA activate_extensions= not working

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
9 Posts 2 Posters 2.6k Views
  • 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.
  • R Offline
    R Offline
    refaQtor
    wrote on last edited by
    #1

    I've got a good working application that uses SQLite. I've cross-compiled the Android SQLite lib, and gotten it to load on Android .

    But, the problem now is that to actually encrypt the data (it all continues to work fine un-encrypted) According to the SQLite Encryption Extension docs, I'm supposed to execute thes PRAGMAs ont he db IMMEDIATELY AFTER the db .open()... I do it like this:

    void DataStore::lock()
    {
        QSqlQuery active(sqlite);
        active.exec("PRAGMA activate_extensions='see-7bb07b8d471d642e';");
        qDebug() << "active last error: " << active.lastError();
    //no errors occurred
    
        QSqlQuery key(sqlite);
        key.exec("PRAGMA key='sqlite3';");
        qDebug() << "key last error: " << key.lastError();
    //no errors occurred
    }
    

    which is what I have confirmed is the correct PRAGMAs from the SQLite encryption extension folks. I get no errors, nor do I get encryption.

    Has anyone any done this before? any ideas?
    Could there be something internally to the Qt code that executes between the PRAGMAs and the actual SQLite open()?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What version of SQLite are you using ?

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

      R 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        What version of SQLite are you using ?

        R Offline
        R Offline
        refaQtor
        wrote on last edited by
        #3

        @SGaist SQLite source code version-3.21.0 specifically the "see" (SQLite Encryption Extension) purchased & Qt 5.91

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Did you rebuild the SQLite plugin to use your custom version of SQLite ?

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

          R 1 Reply Last reply
          0
          • SGaistS SGaist

            Did you rebuild the SQLite plugin to use your custom version of SQLite ?

            R Offline
            R Offline
            refaQtor
            wrote on last edited by
            #5

            @SGaist I'm not sure what you mean. the Qt\5.9.1\android_armv7\plugins\sqldrivers\qsqlite.so file?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              For example, yes. I mean that if you are building your application for different targets, you need to build/re-build the QSQLite plugin for each of them.

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

              R 1 Reply Last reply
              0
              • SGaistS SGaist

                For example, yes. I mean that if you are building your application for different targets, you need to build/re-build the QSQLite plugin for each of them.

                R Offline
                R Offline
                refaQtor
                wrote on last edited by
                #7

                @SGaist ? my application continues to run on windows and linux and Android and iOS - all hitting the SQLite db. I never once rebuilt that file, or any of Qt specifically.

                I believe that my app is linking to the actual binary libsqlite.so (that the libqsqlite.so plugin would link to) because, when I (with a hex editor) change the few bytes at the beginning of my libsqlite.so, then the db does fail on Android - I see that it fails to link on the console output. When I restore the bytes, it works again. But, I could be misinterpreting that somehow.

                I'd never heard of compiling this plugin separately: qsql_sqlite.cpp. Is that what you mean?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  AFAIR, if you don't use your system provided SQLite library, the plugin is built with Qt's internally provided SQLite which is built statically for that matter. Hence my question about re-building the QSQLite plugin using your custom version.

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

                  R 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    AFAIR, if you don't use your system provided SQLite library, the plugin is built with Qt's internally provided SQLite which is built statically for that matter. Hence my question about re-building the QSQLite plugin using your custom version.

                    R Offline
                    R Offline
                    refaQtor
                    wrote on last edited by
                    #9

                    @SGaist thank you for steering me in that direction. I'm investigating that stuff now.

                    1 Reply Last reply
                    0

                    • Login

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