I am having issues trying to encrypt a SQLite database. I have tried numerous things so far but none seem to work.
- Initially I have used the (unsupported)
SQLiteConnection.SetPassword()
method provided bySystem.Data.SQLite
, however since a while this method has been removed from theSystem.Data.SQLite
package. Trying to take an older SQLite version turned out to be difficult since UWP is UAP and not .NET Framework. - Therefore I have moved to
Microsoft.Data.Sqlite.Core
and used this documentation for installing theSQLitePCLRaw.bundle_e_sqlcipher
package and calling eitherSQLitePCL.Batteries_V2.Init()
orSQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provided_e_sqlcipher())
. Then executing the queryPRAGMA KEY = 'password'
does not encrypt the database file. - I have also seen posts where people used
SQLitePCLRaw.bundle_sqlcipher
rather than...e_sqlcipher
however in that case the...V2.Init()
did not work. - I have also looked into using
sqlite-net-sqlcipher
however executingSQLiteConnection.Query<int>("PRAGMA key = 'password'");
does also not encrypt the database. When trying to query to the database usingkey: "password"
will then result inThe file is no database
error denoting the lack of password on the database.
How can I encrypt a SQLite database for UWP, preferably using Microsoft.Data.Sqlite
but other options are fine as well.
I am also primarily looking for a free way to achieve this, since $900 is quite over-budget for the project I am working on.