This sample is a minimal encrypted journal built directly on SQLitePCLRaw. It
does not use Microsoft.Data.Sqlite, Entity Framework, sqlite-net, or another
managed database layer. Provider selection, open, activation, keying,
preparation, binding, stepping, column reads, finalization, and close all use
the SQLitePCL.raw API.
- .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.
In PowerShell:
$env:SQLITE_ENCRYPTED_ACTIVATION_KEY = '<activation key without the see- prefix>'
$env:SQLITE_ENCRYPTED_DATABASE_KEY = '<database key>'The activation key licenses SEE for this process. The database key encrypts
journal.db. Keep both out of source control and command-line arguments.
To put the database somewhere else:
$env:SQLITE_ENCRYPTED_DATABASE_PATH = 'C:\data\private-journal.db'cd sqlite-encrypted-dotnet-console-journal
dotnet restore
dotnet run -- add "Release notes" "Finished the encrypted console sample"
dotnet run -- list
dotnet run -- show 1
dotnet run -- search encrypted
dotnet run -- update 1 "Release notes" "Reviewed and ready"
dotnet run -- delete 1Arguments containing spaces must be quoted.
EncryptedDatabase.Open performs this sequence before the repository runs any
schema or application SQL:
- Select and freeze
SQLite3Provider_e_sqlite3during application startup. - Open the database with
raw.sqlite3_open. - Activate SEE with
PRAGMA activate_extensions = 'see-…'. - Execute
PRAGMA keyand require its first result to beok. - Read
sqlite_masterso a wrong key for an existing database fails before schema creation or migration.
After that, all CRUD uses prepared statements, bound parameters, explicit
sqlite3_step result checks, and deterministic statement disposal.
Publish for the target platform so .NET selects the corresponding 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