SQlCipher for android Xamarin

1.5k views Asked by At

I have sqllite database and need to crypt/encrypt it, data inside database should not be available for everyone...

My application is written in Xamarin, After research I found out SQLCipher component for android, but also there is free version in github... Is it possible to use this for Xamarin, with binding libraries, or something like that

2

There are 2 answers

1
JordanMazurke On

While in theory this is possible you have to consider whether it is actually worth the effort to create the necessary bindings. If you look at the component on the Xamarin component store there is also a comment suggesting there is some differences between the free binaries available on the SQLCipher site versus what is included in the component - this should be a cause for concern.

That been said, the following link should give you the background to get started:

Android Wrappers

Good luck

0
Ashray P. Shetty On
Hi I've successfully implemented the sqlcipher in my Xamarin Forms app.

The nuget packages I'm using are :

1. PCL project :
 a. sqlite-net-pcl by Frank A. Krueger - version 1.4.118
 b. SQLitePCLRaw.bundle_green - by Eric Sink, version 1.1.9
 c. SQLitePCLRaw.bundle_sqlcipher - by Eric Sink, version 1.1.9
 d. SQLitePCLRaw.core - by Eric Sink version, 1.1.9 

2. Droid project :
 a. sqlite-net-pcl by Frank A. Krueger - version 1.4.118
 b. SQLitePCLRaw.bundle_green - by Eric Sink, version 1.1.9
 c. SQLitePCLRaw.bundle_sqlcipher - by Eric Sink, version 1.1.9
 d. SQLitePCLRaw.core - by Eric Sink version, 1.1.9
 e. SQLitePCLRaw.lib.e_sqlite3.android - by Eric Sink version, 1.1.9
 f. SQLitePCLRaw.lib.sqlcipher.android - by Eric Sink version, 1.1.9
 g. SQLitePCLRaw.provider.e_sqlite3.android - by Eric Sink version, 1.1.9
 h. SQLitePCLRaw.provider.sqlcipher.android - by Eric Sink version, 1.1.9

3. iOS project
 a. sqlite-net-pcl by Frank A. Krueger - version 1.4.118
 b. SQLitePCLRaw.bundle_green - by Eric Sink, version 1.1.9
 c. SQLitePCLRaw.bundle_sqlcipher - by Eric Sink, version 1.1.9
 d. SQLitePCLRaw.core - by Eric Sink version, 1.1.9
 e. SQLitePCLRaw.lib.sqlcipher.ios_unified.static - by Eric Sink version, 1.1.9
 f. SQLitePCLRaw.provider.internal.ios_unified - by Eric Sink version, 1.1.9
 g. SQLitePCLRaw.provider.sqlite3.ios_unified - by Eric Sink version, 1.1.9

Then in your Database class you have to create an connection object SQLConnection.

Then during creating sqlconnection object, if you want to have sqlcipher, you have to add Pragmakey :

    SQLiteConnection connection = new SQLiteConnection("database path");         
        string password = "$1234#";        

        if (!string.IsNullOrEmpty(password))
        {
          connection.Query<int>("PRAGMA key='?'", password);
        }
          return connection;

Hope this helps!!!