Adding SQLCipher to a Xamarin project

Hi,
Is there any documentation on how to implement SQLCipher in a Xamarin Forms project.
I have taken over a project and I have been told it has SQLCipher already present. I now need to upgrade SQLCipher to v4.01
It uses SQLLite.NetPCL (3.1.1) but I can not see how SQLCipher has been set in the project.

There is really only this piece of code present in both iOS and Android code
_asyncConnection.ExecuteScalarAsync(String.Format(“PRAGMA cipher_license = ‘{0}’;”, Common.Helpers.Settings.SqliteCipherLicence));

There are no references to SQLCipher (NuGet packages) in either iOS or Android projects.
What Nuget package am I supposed to install? etc etc.

Hello @sammacdougall

There are a couple of resources you might want to review. First, there are some major changes in the latest SQLCipher 4 series that you should be aware of. We cover migration of database file formats here. Next, we have a write up that covers upgrading the client libraries from the 3.x series to the new 4.x series here. Finally, we have steps for setting up the a new project which includes Xamarin here. Would you review those links and and let us know if you have any additional questions? Thanks!

Hi Nick,

Thanks for the links.
I had been looking through these.

The problem is I have taken over this project and I do not have any of the details of how this was implemented and as I look at the examples it does not look as though it has been implemented in any way like
https://www.zetetic.net/sqlcipher/sqlcipher-for-dotnet/ suggests.

This project is a xamarin forms project running NetStandard 2.0.3. With an iOS and Android project.

What is in place at the moment is

within Xamarin sln Nuget packages…

SQLite.Net.Async-PCL
SQLite.Net-PCL

The android project has a reference to…

sqlcipher-xamarin-android (3.4.2.1)

The ios project has a reference to…

sqlcipher-xamarin-ios

The nuget.config sits under the Solutions items

And the nuget packages sit in the root of the project

sqlcipher-xamarin-android.3.4.2.1.nupkg

sqlcipher-xamarin-ios.3.4.2.1.nupkg

There are no references in the present project to

SQLitePCLRaw.batteries_sqlcipher
SQLitePCLRaw.batteries_v2
SQLitePCLRaw.core
SQLitePCLRaw.lib.sqlcipher
SQLitePCLRaw.provider.sqlcipher

And when I try to upgrade the project to the latest 4.0 version it does not come up in the nuget packages it does not appear to exist?

The only line of code that I can see in the project to initialise the db is this…
_asyncConnection.ExecuteScalarAsync(String.Format(“PRAGMA cipher_license = ‘{0}’;”, Common.Helpers.Settings.SqliteCipherLicence));

There is no initialisation in iOS as shown in your link i.e.

SQLitePCL.lib.embedded.Init(); /* required on iOS to link SQLCipher library */
SQLitePCL.Batteries_V2.Init();

Do you think this has been implemented incorrectly?

Kind regards,

Sam

Hi,

I was following up on this as I have not had a response.
My question is has the previous developer implemented this properly in Xamarin. By all accounts, it does not appear so as it does not represent what you have on your site and is missing many of the references.
If this is the case then I do not need to worry about an upgrade path to the 4 release as by all accounts the DB is not encrypted yet.
Also, what am I doing incorrectly that I can not see the latest 4.0 version NuGet package when I search for it.

Kind regards,

Sam

Hello @sammacdougall - thanks for getting back to us with the details here, and sorry for the confusion. It sounds like you were previously using the Commercial Edition of SQLCipher. These libraries are distributed via private NuGet packages only - they are not available from public NuGet sources. Thus, you would need to get the latest copy of the packages from us to install in order to upgrade to SQLCipher 4 and for the referenced instructions to work.

Can you reach out to us at support@zetetic.net at your earliest convenience, and let us know the company name that licensed the product so we can look it up?