dartpub.dev DartNative · beta
plugins / native_sqlcipher
na

native_sqlcipher

v0.1.1 MIT

Encrypted SQLite databases for DartNative on iOS and Android.

Native SQLCipher 4.10.0 databases with passphrase keys, bound parameters, synchronous transactions, nested savepoints, and schema versions. Supports iOS and Android through FFI. SQLCipher is distributed under its separate BSD license.

by tayormi/native_sqlcipher · DartNative ≥ 3.0 · updated 4 days ago
Install
Free
pubspec.yaml
dependencies:
  native_sqlcipher:
    hosted: https://dartpub.dev
    version: ^0.1.1
Weekly installs
1
Active apps
3
Rating
0.0 · 0
Open issues
0

native_sqlcipher

Encrypted SQLite databases for DartNative, powered by SQLCipher 4.10.0. Supports iOS and Android.

Install

Add to your DartNative app's pubspec.yaml:

dependencies:
  native_sqlcipher:
    hosted: https://dartpub.dev
    version: ^0.1.1

Run dn pub get, then rebuild the app to link the native plugin. Use the generated plugin registrant provided by your DartNative app template.

Use

import 'dart:typed_data';
import 'package:native_sqlcipher/native_sqlcipher.dart';

// Supply a writable path and a passphrase from your secure storage.
void saveNote(String databasePath, Uint8List passphrase) {
  final db = SqlCipherDatabase.open(
    databasePath,
    key: passphrase,
    create: true,
  );
  try {
    db.execute('CREATE TABLE IF NOT EXISTS notes (body TEXT NOT NULL)');
    db.execute('INSERT INTO notes (body) VALUES (?)', ['Hello']);
    final notes = db.select('SELECT body FROM notes');
    print(notes);
  } finally {
    db.close();
  }
}

Notes

  • Passphrase bytes are used to derive the encryption key. Keep them in secure storage; do not hardcode them.
  • Opening an existing database is the default. Use create: true only when creating one is intended. Wrong keys throw SqlCipherException.
  • Queries and transactions are synchronous. Use a worker isolate for longer operations, and keep transaction callbacks synchronous.
  • Native targets require iOS 15+ or Android API 26+. Your DartNative SDK may require a newer OS.

Supports bound parameters, transactions, nested savepoints, and SQLite schema versions. See API notes for details and native linking requirements.

MIT license. SQLCipher has a separate BSD license.