dotnet-sqlcipher-encryption

Implements SQLCipher-encrypted SQLite in .NET with raw keys, key derivation, and pluggable key sources.

2|Updated Jul 18, 2026
One-click install
npx skills add https://github.com/Arasz/ai-badger --skill dotnet-sqlcipher-encryption-arasz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-sqlcipher-encryption
Source: https://github.com/Arasz/ai-badger/tree/main/features/dotnet/skills/dotnet-workload/references/dotnet-sqlcipher-encryption
Command: npx skills add https://github.com/Arasz/ai-badger --skill dotnet-sqlcipher-encryption-arasz

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Encrypting SQLite databases at rest in .NET with SQLCipher involves subtle traps: raw-key versus passphrase modes, PRAGMA rekey constraints with WAL, key-source selection that cannot live inside the encrypted store, and Dapper mapping failures over SQLite3MC. This Skill captures measured, verified guidance so these pitfalls are avoided instead of rediscovered. ## Core Features & Use Cases - Raw 256-bit key channel: Key the database with Password = "x'<64-hex>'" for no-KDF, brute-force-resistant encryption, including deriving keys from ed25519 SSH private keys via SHA-256 with a stable label. - Rekey and key-source architecture: Covers PRAGMA rekey legs (raw↔raw, passphrase→raw, plaintext→raw), the WAL-unsupported constraint, and a pluggable provider pattern with an unencrypted sidecar file for pre-open source selection. - Bitwarden bws integration and Dapper traps: Documents bws CLI usage, rotation traps, bootstrap ranking for vault tokens, and measured Dapper-over-SQLite3MC failures such as Int64 count columns and NULL-typed aggregates. - Use Case: A .NET service storing sensitive data in SQLite needs to switch its encryption key source from an environment variable to Bitwarden Secrets Manager without bricking existing databases; this Skill provides the rekey ordering, crash-recovery legs, and sidecar pattern to do it safely. ## Quick Start Ask the agent to set up SQLCipher encryption for a .NET SQLite database using a raw 256-bit key derived from an ed25519 SSH key, following this Skill's guidance.

Frequently Asked Questions about dotnet-sqlcipher-encryption

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I encrypt a SQLite database with SQLCipher in .NET?

Use the SQLitePCLRaw e_sqlite3mc bundle and pass the key through SqliteConnectionStringBuilder.Password. The strongest option is a raw 256-bit key formatted as x'<64-hex>', which skips the KDF and removes the passphrase brute-force surface.

How do I derive a SQLCipher key from an ed25519 SSH private key?

Parse the OpenSSH private key, take the 32-byte seed from the private half, and compute SHA-256 of a stable label concatenated with the seed. Only unencrypted ed25519 keys work; RSA encodings are non-canonical and passphrase-protected keys must be rejected.

Does PRAGMA rekey work with WAL mode in SQLCipher?

No, WAL is unsupported for rekey operations. Switch the journal mode to DELETE before running PRAGMA rekey with the target x'...' literal, then switch back to WAL afterward.

Why does Dapper fail with Byte[] signature errors over SQLite3MC?

Dapper builds its typed deserializer eagerly from the reader schema, so aggregates over empty sets come back NULL-typed as byte[] and fail even with zero rows. Use ExecuteScalarAsync<double?> for aggregates or the dynamic QueryAsync path for empty GROUP BY results.

Should I use the Bitwarden Secrets SDK or the bws CLI in .NET?

Prefer the bws CLI when installed. The Bitwarden.Secrets.Sdk 1.0.0 is beta, synchronous-only, carries a custom non-OSI license, and bundles a roughly 7 MB native binary, making it suitable only for embedded setups without CLI access.

What happens if I rotate a Bitwarden secret without rekeying the database?

Rotating the secret in the Bitwarden web UI without running PRAGMA rekey bricks the encrypted database, because the stored key material no longer matches. Any configuration command must warn about this rotation trap before completing.