drift
drift copied to clipboard
Encryption - cross platform
I've been using moor on some side projects for a while and love it. I've recently moved the project across to ffi/web so I can support web plus android & ios. That works great too.
I'm looking at migrating the project for my main work across from sqlite to moor as there's a requirement for a web app, but we are using the encrypted version of sqlite.
I've read here https://moor.simonbinder.eu/docs/other-engines/encryption/ about encryption, but that's talking about using FlutterQueryExecutor but if moving to ffi and web is it possible to have encryption also?
The encrypted executor uses sqflite_sqlcipher
as implementation, which supports iOS, Android and macOS. If you don't need another OS or a moor_ffi
-only feature, using that would probably be the best approach.
At the moment, we don't support an encrypted version of moor_ffi
. The actual implementation would be rather straightforward (just switch the sqlite shared library to SQLCipher and set a password pragma). It looks like I'd have to publish precompiled shared libraries for SQLCipher though.
Using SQLCipher
on the web would probably be a hassle, but you can encrypt the stored data yourself. In the next moor version, you could provide your own MoorWebStorage
implementation that encrypts on the way.
is encryption supported on web ?
No it's not at the moment, although it may be worth noting that it provides little benefit in browsers. Your data is already origin-private, so other websites don't have access to it. And someone controlling the browser would have access to the unencrypted database when it's loaded in memory either way.