Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How To Hide A Source File(.db)
qazaq408 last edited by aha_1980
qt5.7 + sqlite3
My programme need some data when it's running. That data is a lot ,and programme need read data frequently,So I write data to database(sqlite3),And then ,I put the file in sourcefile like this.
/<RCC> <qresource> .......... <file>DataFile/SystemPix.db</file> ......... </qresource> </RCC>
And I connect sqlite3 in the progamme
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabase(":/DataFile/SystemPix.db"); if(!(db.open()) qDebug()<<"Can't Connect Database.";
As you see,progamme tell me "Can't Connect Database.".....
Someone tell me do like this
QFile fs(databaseFile); //databaseFile is a path of file like "/home/MyPro/RecordCard/Ds/pix.db" if(!(fs.exist())) QFile::copy(":/DataFile/SystemPix.db",databaseFile); QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabase(databaseFile); //... //..
And then , I can connect the database,but this is a problem , user can look the data but I hope hide the data to user, even I delete the file when progamme is over , user also can look file(.db) when progamme is running.
How could I hide the Data?If I don't copy file to some dir ,progamme can't connect the database(.db file),if I copy file to some dir,user can look at the data,do you have any good idea?
[Edit aha_1980: fixed title]
my guess is, that the sql driver needs write access to the DB file.
Even if you don't plan to update/alter the data in the DB directly, the DB itself handles some stuff in the back and needs to keep it's state consistent and writes some stuff into the db file.
JonB last edited by JonB
Just how secure (against user looking at file) do you need/expect to be? E.g. do you just want to prevent casual user from easily seeing the file, or do you want to hide it robustly from experienced user/hacker?
Furthermore/alternatively, are you prepared to pay for software which will protect your data against inspection? And/or are you using SQLite3?
Pablo J. Rogina last edited by
@qazaq408 please keep in mind that when you use Qt resource system, the items you add to the RCC file will end up embedded into the executable of your application. The main use of this is to store small icons, translation files, etc.
So, although nothing prevents you to embed your physical .db file into your app's executable, the SQLite driver is expecting a file in the filesystem that's your first "Can't Connect Database." issue.
See this similar post with a suggestion for changing the SQLite driver itself to access Qt's resource file system but even if you do that, I guess your DB will be read-only (if not, you'll be updating the executable file every time you write to the DB...)
How could I hide the Data?
Have you consider using SQLite encryption extension? spoiler alert: I've never used it myself.