EncryptionOptions class final

Options controlling if and how a database should be encrypted.

Setup

Enabling encryption requires additional setup depending on the target platform.

Native

On native platforms, the sqlite3 package provides a copy of SQLite with your app. To use encryption, we need to replace SQLite with SQLite3MultipleCiphers or SQLCipher. To enable that, add this to your pubspec.yaml:

hooks:
  user_defines:
    sqlite3:
      source: sqlite3mc # or sqlcipher

If you're using pub workspaces, this needs to be added to the pubspec.yaml defining the workspace.

Web

Using SQLite3MultipleCiphers is also required for the web. Each release or the PowerSync SDK provides both a sqlite3.wasm and a sqlite3mc.wasm file.

To use encryption, download sqlite3mc.wasm as web/sqlite3.wasm. If you use the powersync:setup_web tool to download that file, pass the --encryption option.

Note that SQLCipher is not available on the web.

Constructors

EncryptionOptions({required String key, bool sqlcipherCompatibility = !_isWeb})
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
key → String
The key used to encrypt the database file.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sqlcipherCompatibility → bool
Whether to use an encryption scheme that is compatible with SQLCipher- based databases when SQLite3MultipleCiphers is enabled.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pragmaStatements({EncryptedSqliteVariant variant = EncryptedSqliteVariant.sqlite3MultipleCiphers}) → Iterable<String>
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

checkHasCipherPragma(CommonDatabase database) → void
Throws if the cipher pragma doesn't exist, as that indicates that SQLite3MultipleCiphers is not available.