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.SQLitepackage. 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.Coreand used this documentation for installing theSQLitePCLRaw.bundle_e_sqlcipherpackage 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_sqlcipherrather than...e_sqlcipherhowever in that case the...V2.Init()did not work. - I have also looked into using
sqlite-net-sqlcipherhowever 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 databaseerror 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.