DATE:
AUTHOR:
PowerSync Product Team
Flutter SDK FLUTTER PACKAGES/LIBRARIES

SQLCipher Support for On-Device Database Encryption for PowerSync + Flutter (Beta)

DATE:
AUTHOR: PowerSync Product Team

We are excited to announce the beta release of SQLCipher support for Flutter apps built with PowerSync. SQLCipher brings robust on-device database encryption, allowing developers to protect sensitive data and meet legal requirements regarding the handling of personal user data.

SQLCipher provides transparent, secure 256-bit AES encryption of SQLite database files. It works by using an encryption key or passphrase which is used to derive an actual encryption key. This key/passphrase must be provided each time the database is accessed. SQL queries, inserts, updates, and other operations continue to work as they would with an unencrypted SQLite database. 

Usage

Install the powersync_sqlcipher SDK:

flutter pub add powersync_sqlcipher

Note: Existing users migrating to this SDK should uninstall the powersync SDK (Flutter SDK without encryption) used previously. The powersync_sqlcipher SDK provides all the functionality of powersync, while enabling encryption.

To enable encryption via SQLCipher, add your encryption key to the database factory constructor:

import 'package/powersync_sqlcipher/powersync.dart';

/// Global reference to the database
late final PowerSyncDatabase db;
final cipherFactory = PowerSyncSQLCipherOpenFactory(
      path: path, key: "sqlcipher-encryption-key"); // https://www.zetetic.net/sqlcipher/sqlcipher-api/#key

db = PowerSyncDatabase.withFactory(cipherFactory, schema: schema);

See the package README for more information.

Help and feedback

If you need any help getting started or have any questions, chat with us on Discord. We'd also love to hear your feedback.

Powered by LaunchNotes