sqliteencryptionxamarinmvvmcrosssqlcipher

Can i use encrypt/decrypt SQLite in MvvmCross


Give me the way, how i can encrypt/decrypt SQLite with MvvmCross, please.

I'm writing the app on Xamarin for two platforms, iOS and Android. And i'm using MvvmCross in the project.

I'm so confused.

The better way is SQLitePCL.raw with sqlcipher, i guess. But i don't know how exactly combine sqlcipher with SQLitePCL.raw. I can use some SQLitePCL.plugins.* for adding "sqlcipher provider" to each platform, but how it use on C# level? How i can set PRAGMA key into my C# code, for example?


Solution

  • For me the answer was to use that scheme.

    For Core project I used next packages:

    SQLitePCLRaw.core
    SQLitePCLRaw.bundle_sqlcipher
    

    For iOS project:

    SQLitePCLRaw.core
    SQLitePCLRaw.bundle_sqlcipher
    SQLitePCLRaw.lib.sqlcipher.ios_unified.static
    SQLitePCLRaw.provider.internal.ios_unified
    

    And for Android project:

    SQLitePCLRaw.core
    SQLitePCLRaw.bundle_sqlcipher
    SQLitePCLRaw.lib.sqlcipher.android
    SQLitePCLRaw.provider.sqlcipher.android
    

    Before you will try to use any method from SQLitePCLRaw packages you need setup provider. For that you just have to input one line of code:

    SQLitePCL.Batteries.Init();
    

    More information about SQLitePCLRaw packages on github