Lighter icon indicating copy to clipboard operation
Lighter copied to clipboard

Support encrypted databases

Open davedelong opened this issue 11 months ago • 1 comments

I'd be very interested to see support for including open source extensions to sqlite, such as SQLCipher.

davedelong avatar Mar 19 '24 15:03 davedelong

Generally I think Lighter should just work w/ a direct fork of SQLite like SQLCipher which has the exact same API like SQLite.

For the non-raw API (Lighter module) one might need a custom ConnectionHandler to pass in the encryption key.

The key question is how one would embed SQLCipher. It has a CocoaPod which apparently shows up and overrides the systems SQLite3 module? Looks like there are no plans to provide an SPM package as well: https://github.com/sqlcipher/sqlcipher/issues/371

Either way, I think we should provide a configuration that allows the user to override how SQLite is imported in generated code. So that one could say it is import SQLCipher instead of import SQLite3.

Though that doesn't help with Lighter as a lib. That could have something like:

#if canImport(SQLCipher)
import SQLCipher
#elseif canImport(SQLite3)
import SQLite3
#else
#error "Could not locate SQLite library."
#endif

I think I'm willing to do that, but it should be clear what SQLite alternatives should be supported and what SPM packages they would come wrong.

Good feature request, I'd also like to have encrypted SQLite!

helje5 avatar Mar 20 '24 14:03 helje5