PDA

View Full Version : SQLCipher, Windows and Mac OS



mtnbiker66
11th October 2012, 19:53
Afternoon all --

I've managed to perform a minor miracle and have compiled SQLCipher in Windows and on my Mac (following these instructions: https://sites.google.com/site/lukeshq/engineering-articles/compiling-sqlcipher-for-windows and http://www.qtcentre.org/wiki/index.php?title=Building_QSQLITE_driver_with_AES-256_encryption_support_(Linux) (http://http://www.qtcentre.org/wiki/index.php?title=Building_QSQLITE_driver_with_AES-256_encryption_support_(Linux)). On the Mac, w/out doing anything beyond the directions, when I execute the following code,


#include <QtGui>
#include <QtSql>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
qDebug() << QSqlDatabase::drivers();
return 0;
}


"QSQLCIPHER" does indeed show up. In Windows, I have modified my .pro to point to the new libraries accordingly, like so:

win32 {
message("Compiling for Windows!")
LIBS += \
c:\sqlcipher\.libs\libeay32.lib \
c:\sqlcipher\.libs\libsqlite3.a \
c:\sqlcipher\.libs\libgcc.a

INCLUDEPATH += c:\sqlcipher\
}

but I *don't* see QSQLCIPHER using the same main.cpp

So, now I'm stuck as to what to "include" to use SQLCipher on both platforms, and there's not much documentation out there about that. I tried to open my DB (that's non-encrypted right now) using SQLCipher on the Mac, and the database didn't open (and the error told me nothing). Obviously I'm missing something easy, possible the correct "include", so please feel free to embarrass me in getting beyond this. I'm stuck on the Windows side trying to make the code "see" SQLCipher and then on both platforms actually using it.


Kodi

ps -- still googling in the meantime and will update if I figure it out

Ed. additional question -- is the sqlite3.h file created in the sqlcipher directory something I know need to be including? Should move it to build directory and/or add that directly into my project? Also, I found this link: https://code.google.com/p/qsqlcipher4win/downloads/list with a pre-compiled .dll (or course, after I spend hours creating a static one). Will I know how to add a library to my project I still can't get Windows working, and I think it's got something to do with the header file and making sure I have the right library linked in.

mtnbiker66
18th October 2012, 20:35
Update:

Still having trouble creating a library in Windows but I have generated the libraries on my Mac. Incorporated them into my project, but that's going haywire -- when I open my DB, which is unencrypted, using "QSQLCIPHER", I don't see any existing data in my models (I can see the data when opening with "QSQLITE"); however, executing direct queries/insert/deletes work just fine. In addition, while I can add data to my models, upon submitALL(), I get errors (near "," syntax error).

Also, my app creates a DB w/all the necessary tables and seed data if one is not found, and the PRAGMA command doesn't appear to be actually encrypting the DB when I do this; the exec() returns isactive = TRUE but when I bring up the DB outside of my app, the data is not encrypted. I do make sure that's the first command I issue after my db.open() command for a new and an existing DB.

Kodi

mtnbiker66
14th November 2012, 17:55
Another update:

In Windows I've FINALLY managed to generate a dynamic library for SQLCIPHER in Windows, but I still can't see it in my app. I've copied the qsqlcipher4.dll to /plugins/sqldrivers folder along with libeay32.dll, but it won't load. From what I was reading it doesn't seem like modifications need to be made to my project file, but even when at add LIB += with the paths, that doesn't work either. I'm just wondering if anyone else can see the plugin in their app, and if so, what steps need to be done that I haven't? make install worked but now I'm stuck