Sqlite-net: Is it possible to protect sqlite db with password?

Created on 17 Jul 2017  路  3Comments  路  Source: praeclarum/sqlite-net

Hello,

I found some topics related to this on stackoverflow and tried, but not working.
There is no methods SetPassword, ChangePassword in SQLiteConnection.

var documentspath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var path = Path.Combine(documentspath, DATABASE_NAME);
String dbConnection = "Data Source = " + documentspath + "; Version = 3; Password = test";
connection = new SQLiteConnection(dbConnection);

I tried to create connection with connectionpath, like below,
Data Source = /data/user/0/SqliteExample.SqliteExample/files/sqlite_plain.db; Version = 3; Password = test (CannotOpen)

But I'm getting error.
SQLite.SQLiteException: Could not open database file: Data Source = /data/user/0/SqliteExample.SqliteExample/files/sqlite_plain.db; Version = 3; Password = test (CannotOpen)

07-17 13:51:27.029 I/MonoDroid( 5435): UNHANDLED EXCEPTION:
Thread started: #7
Thread started: #8
07-17 13:51:27.048 I/MonoDroid( 5435): SQLite.SQLiteException: Could not open database file: Data Source = /data/user/0/SqliteExample.SqliteExample/files/sqlite_plain.db; Version = 3; Password = test (CannotOpen)
07-17 13:51:27.048 I/MonoDroid( 5435): at SQLite.SQLiteConnection..ctor (System.String databasePath, SQLite.SQLiteOpenFlags openFlags, System.Boolean storeDateTimeAsTicks) [0x0004f] in /Users/fak/Dropbox/Projects/sqlite-net/src/SQLite.cs:224
07-17 13:51:27.048 I/MonoDroid( 5435): at SQLite.SQLiteConnection..ctor (System.String databasePath, System.Boolean storeDateTimeAsTicks) [0x00000] in /Users/fak/Dropbox/Projects/sqlite-net/src/SQLite.cs:181
07-17 13:51:27.048 D/Mono ( 5435): [0x9b07f930] worker starting
07-17 13:51:27.048 I/MonoDroid( 5435): at SqliteExample.PlainSqliteConnection.getInstance () [0x00054] in D:SessionSqliteExamplePlainSqliteConnection.cs:32
07-17 13:51:27.048 I/MonoDroid( 5435): at SqliteExample.PlainSqliteScreen.CreateDB () [0x00001] in D:SessionSqliteExamplePlainSqliteScreen.cs:38
07-17 13:51:27.048 I/MonoDroid( 5435): at SqliteExample.PlainSqliteScreen.b__12_0 (System.Object sender, System.EventArgs e) [0x00001] in D:SessionSqliteExamplePlainSqliteScreen.cs:96
07-17 13:51:27.048 I/MonoDroid( 5435): at Android.Views.View+IOnClickListenerImplementor.OnClick (Android.Views.View v) [0x0000d] in /Users/builder/data/lanes/4009/3a62f1ea/source/monodroid/src/Mono.Android/platforms/android-25/src/generated/Android.Views.View.cs:1892
07-17 13:51:27.048 I/MonoDroid( 5435): at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x00011] in /Users/builder/data/lanes/4009/3a62f1ea/source/monodroid/src/Mono.Android/platforms/android-25/src/generated/Android.Views.View.cs:1857
07-17 13:51:27.048 I/MonoDroid( 5435): at (wrapper dynamic-method) System.Object:7b4812ea-494c-4567-9cac-abb1a02ef44f (intptr,intptr,intptr)

Feature Up for Grabs

Most helpful comment

@MKuckert yep we're working on it on #597

I'm going to close this as a repo of that.

All 3 comments

Yeah sorry SQLite-net doesn't support ADO.NET connection strings.

This is a good request though - it would be nice to support passwords.

SQLitePCL.raw provides a sqlcipher provider (see https://github.com/ericsink/SQLitePCL.raw/#included-providers) but I don't know how to correctly install those NuGet packages besides sqlite-net as later references SQLitePCLRaw.bundle_green which selects a default unencrypted implementation.

Maybe @ericsink can help?

@MKuckert yep we're working on it on #597

I'm going to close this as a repo of that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

newtoncw picture newtoncw  路  7Comments

danielPollackGitHub picture danielPollackGitHub  路  5Comments

ToddThomson picture ToddThomson  路  3Comments

yaliashkevich picture yaliashkevich  路  3Comments

plamen-i picture plamen-i  路  6Comments