SQLCipherSharp3 2.0.1

dotnet add package SQLCipherSharp3 --version 2.0.1
                    
NuGet\Install-Package SQLCipherSharp3 -Version 2.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SQLCipherSharp3" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SQLCipherSharp3" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="SQLCipherSharp3" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SQLCipherSharp3 --version 2.0.1
                    
#r "nuget: SQLCipherSharp3, 2.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SQLCipherSharp3@2.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SQLCipherSharp3&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=SQLCipherSharp3&version=2.0.1
                    
Install as a Cake Tool

SQLCipherSharp3 Documentation

Overview

SQLCipherSharp3 encrypts and decrypts SQLite databases in a way that is compatible with SQLCipher 3.x. It uses AES-256-CBC encryption, PBKDF2 key derivation, per-page HMAC (SHA1), and defensive validation (constant-time HMAC comparison, config checks).

Installation

  • Package Manager: Install-Package SQLCipherSharp3
  • .NET CLI: dotnet add package SQLCipherSharp3

Quick Start

Encrypt a database

using System.IO;
using System.Text;
using SQLCipherSharp3;

byte[] plaintext = File.ReadAllBytes("path/to/database.sqlite");
byte[] password = Encoding.UTF8.GetBytes("your-secret-password");

var encryptor = new SqlCipherEncryptor();
byte[] encryptedData = encryptor.Encrypt(plaintext, password);
File.WriteAllBytes("path/to/encrypted.db", encryptedData);

Decrypt a database

using System.IO;
using System.Text;
using SQLCipherSharp3;

byte[] encryptedData = File.ReadAllBytes("path/to/encrypted.db");
byte[] password = Encoding.UTF8.GetBytes("your-secret-password");

var decryptor = new SqlCipherDecryptor();
byte[] decryptedData = decryptor.Decrypt(encryptedData, password);
File.WriteAllBytes("path/to/decrypted.sqlite", decryptedData);

Asynchronous APIs

using System.IO;
using System.Text;
using SQLCipherSharp3;

byte[] plaintext = await File.ReadAllBytesAsync("path/to/database.sqlite");
byte[] password = Encoding.UTF8.GetBytes("your-secret-password");

var encryptor = new SqlCipherEncryptor();
byte[] encrypted = await encryptor.EncryptAsync(plaintext, password);

var decryptor = new SqlCipherDecryptor();
byte[] roundTripped = await decryptor.DecryptAsync(encrypted, password);

Configuration

Create a SqlCipherConfiguration to override defaults:

var config = new SqlCipherConfiguration
{
    PageSize = 1024,
    ReserveSize = 48,
    KeyIterations = 64000,
    HmacKeyIterations = 2
    // other fields available: SaltSize (16 fixed for SQLCipher 3), KeySize, HmacKeySize, IvSize, HmacSize, SaltMask
};

var encryptor = new SqlCipherEncryptor(config);
var decryptor = new SqlCipherDecryptor(config);

Validate() runs automatically in constructors and rejects invalid combinations (e.g., misaligned page sizes).

Exceptions

  • WrongPasswordException: HMAC verification failed (wrong password or corrupted ciphertext).
  • ArgumentException: Null/empty inputs or malformed encrypted data/config.
  • InvalidDataException: Unexpected data layout during decryption.

Testing

dotnet test SQLCipherSharp3.sln

Contributing

Pull requests are welcome. Please run tests before submitting. Issues/feature requests are tracked on GitHub.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.1 202 11/28/2025
2.0.0 204 11/28/2025
1.0.1 196 3/2/2025
1.0.0 186 2/9/2025