Hello,
I am building a non-commercial app to work with an encrypted SQLite database in VB.NET. Note: The database was encrypted with SQLBrowser (SQLCipher) in Windows. I am a hobbyist programmer and my background with packages/dependencies/binaries is a bit limited. Please forgive this.
I am quite confused on how to implement SQLCipher to get it working in my project. Specifically, I was hoping to use it via the System.Data.SQLite namespace. Is this possible?
There is a Nuget package here: sqlite-net-sqlcipher which uses the ‘SQLite’ namespace within .NET. I believe this is the supported opensource project that zetetic has made available on Github. This appears to be a wrapper around SQLite. I would be more comfortable implementing via the System.Data.SQLite library, as my project uses the SQLiteConnection object in that library heavily (which differs from sqlite-net-sqlcipher).
To summarize, I am wondering if System.Data.SQLite is able to use SQLCipher community edition. If so, what steps are required? If not, how do you recommend implementing SQLCipher for use in .NET.
Thank you for your time and assistance.
Hello @BitFlipper88 - thanks for checking out SQLCipher. The project you referenced, sqlite-net-sqlcipher, is an Open Source project, but not directly from Zetetic. It incorporates a 3rd party build of SQLCipher based on Community Edition. While we don’t support it directly, it does provide a .NET interface to SQLCipher that could be used from a VB.NET project.
Another alternative would be to use Microsoft.Data.SQLite.Core, along with SQLitePCL.raw. This is also a 3rd party solution based on Community Edition, but Microsoft.Data.SQLite is an ADO.NET provider, so the interface would be more similar to System.Data.SQLite, though not an exact match.
Otherwise, if you would prefer a commercially supported option based directly on System.Data.SQLite, the best solution would be our own SQLCipher for Windows System.Data.SQLite. This is a Commercial Edition library available for purchase from Zetetic that provides an identical API. If you would like to try it, you can request a 15-day free trial here:
SQLCipher Free Trial Request
Hello @sjlombardo
Thank you for clarifying .NET options for SQLCipher. A revisit of the Zetetic documentation on .NET discusses the option of using Microsoft.Data.SQLite.Core. I explored this option and was unsuccessful at getting the SQLitePCL.raw library to interface with the SQLCipher provider. Seems the information on how to use this with .NET + SQLCipher is limited and over my head. There’s also several Nuget packages for PCLraw and it’s providers that adds to confusion. I did find Brice Lambson’s blog post here which discusses how to use this method. But I again, I was unsuccessful.
This leaves me really with 2 options for encryption: The first would be to explore the unsupported, open source .NET interface (sqlite-net-sqlcipher Nuget package), which, as you explained, is not ADO.NET. Playing with this codebase yesterday, It wasn’t apparent to me how to even check if a DB connection was open.
The second option being to build my application with on-the-fly AES-256 encryption/decryption during database transactions. This would unfortunately keep the key in memory during app use, which i’m not particularly fond of—despite this being true for all other technologies including SQLCipher, I’m less knowledgeable at keeping a secret in storage as Zetetic, for instance (locked memory, etc).
I appreciate providing information to a commercial solution, but it exceeds this project’s budget at the current time.
Thank you again.