Anyone successfully used password on sqlite database in Monotouch? Anyone successfully used password on sqlite database in Monotouch? sqlite sqlite

Anyone successfully used password on sqlite database in Monotouch?


As per my research there are a few options for database encryption using MonoTouch. I have a forthcoming blog post on the subject, but for now these are your top two options:

SQLCipher

I've automated the SQLCipher build process substantially. All it takes is a simple make command and you've got a library that you can link into your project. It makes use of the awesome SQLite-NET library. After that, all that's required is to provide the key in the SQLite.cs file.

CSharp-SQLite

This is a managed port of the SQLite library in C#. Performance is only about ~2x slower, which is pretty awesome considering it's not native code!


Try adding ";Password=mypassword" to your connection string, and remove the call to ChangePassword.

Please note that, by default, the iPhone implementation of sqlite does not support encryption, so the sqlite commands for that will be no-ops.

You can get a (paid) copy of the encrypt-able version of sqlite from http://www.hwaci.com/sw/sqlite/see.html, and compile it into your application, making sure to remove the libsqlite3*.dylib from your project if you've linked that in.

You may have to do a bit of digging in the Monotouch documentation and/or experimentation to make sure that the Monotouch library itself is not including the default sqlite implementation, but in fact links to the implementation you specify. Try it first, if things still don't work that's where I'd start looking.

You can do this experiment without paying for the encrypted version, simply using the sqlite3 source code available on the net, with appropriate break points.

Good luck!

PS: Note that there is no comparable solution for Android at this point, this works on iPhone because iPhone runs native C code.

PPS: There is also SQLCipher that claims to encrypt sqlite on iPhone. However I found the configuration requirements to be below my standards for simplicity. I'm also not sure if it will properly insert itself between Monotouch's framework code and the default iPhone sqlite implementation.


SQLCipher for MonoTouch provides full database encryption for SQLite databases.

http://sqlcipher.net/sqlcipher-for-monotouch

There is also a SQLCipher on Mono for Android, which allows you to reuse the same code across Mono Touch and MonoDroid applications

http://sqlcipher.net/sqlcipher-for-monodroid