This sample is a cross-platform desktop notes application built with Avalonia
and the published SQLite.Encrypted NuGet package. It demonstrates encrypted
CRUD and search on Windows, macOS, and Linux.
Database code is isolated in Data/. It uses Microsoft.Data.Sqlite.Core for
idiomatic ADO.NET connections, commands, parameters, and readers. The
SQLitePCLRaw.provider.e_sqlite3 package selects the native e_sqlite3
library supplied by SQLite.Encrypted. Avalonia code stays in
MainWindow.axaml and its code-behind.
- .NET 8 SDK or later
- a SQLite.Encrypted activation key valid for the current platform and SQLite 3.54
Free fully-featured demo keys are available from sqlite.sourcegear.com.
The activation key can be entered in the unlock screen. To prefill it without putting it in source code, set this environment variable:
$env:SQLITE_ENCRYPTED_ACTIVATION_KEY = '<activation key without the see- prefix>'Then restore and run:
cd sqlite-encrypted-dotnet-avalonia-journal
dotnet restore
dotnet runEnter a database passphrase in the unlock screen. The encrypted database is
stored in the current user's local application-data folder under
SQLiteEncrypted/AvaloniaJournal/journal.db. The sample does not persist the
activation key or database passphrase.
Opening the journal performs this checked sequence:
- Configure
SQLite3Provider_e_sqlite3before starting Avalonia. - Open a non-pooled
Microsoft.Data.Sqlite.SqliteConnection. - Activate SEE with
PRAGMA activate_extensions = 'see-…'. - Run
PRAGMA keyand require its first result to beok. - Read
sqlite_masterso a wrong passphrase fails before schema creation.
An invalid activation attempt affects the process-global SEE state. The sample therefore disables another unlock attempt and tells the user to restart the application.
Publish for the intended desktop runtime so .NET selects the matching native
e_sqlite3 asset:
dotnet publish -c Release -r win-x64 --self-contained false
dotnet publish -c Release -r linux-x64 --self-contained false
dotnet publish -c Release -r osx-arm64 --self-contained false