SQLitePCLRaw.bundle_e_sqlite3mc
2.1.7
Prefix Reserved
See the version list below for details.
dotnet add package SQLitePCLRaw.bundle_e_sqlite3mc --version 2.1.7
NuGet\Install-Package SQLitePCLRaw.bundle_e_sqlite3mc -Version 2.1.7
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3mc" Version="2.1.7" />
paket add SQLitePCLRaw.bundle_e_sqlite3mc --version 2.1.7
#r "nuget: SQLitePCLRaw.bundle_e_sqlite3mc, 2.1.7"
// Install SQLitePCLRaw.bundle_e_sqlite3mc as a Cake Addin #addin nuget:?package=SQLitePCLRaw.bundle_e_sqlite3mc&version=2.1.7 // Install SQLitePCLRaw.bundle_e_sqlite3mc as a Cake Tool #tool nuget:?package=SQLitePCLRaw.bundle_e_sqlite3mc&version=2.1.7
SQLite3 Multiple Ciphers NuGet Package
This library provides C#/.NET bindings for SQLite3 Multiple Ciphers. It leverages SQLitePCLRaw to create the bindings.
Table of Contents
- Usage
- Passphrase based database encryption support
- Examples for cipher configuration
- Acknowledgements
- See also
Usage
Because the bindings are built using SQLitePCLRaw, you can use them with various .NET libraries.
⚠️ Warning! Don't use multiple SQLitePCLRaw bundles in the same project.
Microsoft.Data.Sqlite
For Microsoft.Data.Sqlite, be sure to use the Microsoft.Data.Sqlite.Core package instead of the main one to avoid using multiple bundles.
using Microsoft.Data.Sqlite;
using var connection = new SqliteConnection("Data Source=example.db;Password=Password12!");
connection.Open();
var command = connection.CreateCommand();
command.CommandText = "select sqlite3mc_version()";
var version = (string)command.ExecuteScalar()!;
Console.WriteLine(version);
Dapper
Use Dapper with Microsoft.Data.Sqlite by following the same instructions detailed above.
using Dapper;
using Microsoft.Data.Sqlite;
using var connection = new SqliteConnection("Data Source=example.db;Password=Password12!");
var version = connection.ExecuteScalar<string>("select sqlite3mc_version()");
Console.WriteLine(version);
EF Core
EF Core is built on top of Microsoft.Data.Sqlite. Be sure to use the Microsoft.EntityFrameworkCore.Sqlite.Core package instead of the main one to avoid using multiple bundles.
options.UseSqlite("Data Source=example.db;Password=Password12!");
SQLite-net
With SQLite-net, be sure to use the sqlite-net-base package instead of the main one to avoid using multiple bundles.
using SQLite;
SQLitePCL.Batteries_V2.Init();
var connection = new SQLiteConnection(new("example.db", storeDateTimeAsTicks: true, key: "Password12!"));
var version = connection.ExecuteScalar<string>("select sqlite3mc_version()");
Console.WriteLine(version);
Low-level bindings
If you really want to use the low-level bindings directly, you can. But these are primarly intended to be used by libraries like Microsoft.Data.Sqlite and SQLite-net.
using static SQLitePCL.raw;
SQLitePCL.Batteries_V2.Init();
var rc = sqlite3_open("example.db", out var db);
if (rc != SQLITE_OK) return;
using (db)
{
rc = sqlite3_key(db, "Password12!"u8);
if (rc != SQLITE_OK) return;
rc = sqlite3_prepare_v2(db, "select sqlite3mc_version()", out var stmt);
if (rc != SQLITE_OK) return;
using (stmt)
{
rc = sqlite3_step(stmt);
if (rc != SQLITE_ROW) return;
var version = sqlite3_column_text(stmt, 0).utf8_to_string();
Console.WriteLine(version);
}
}
Passphrase based database encryption support
This NuGet package supports access to encrypted SQLite databases from .NET applications. It is based on the project SQLite3 Multiple Ciphers.
SQLite3 Multiple Ciphers is an extension to the public domain version of SQLite that allows applications to read and write encrypted database files. Currently 5 different encryption cipher schemes are supported:
- wxSQLite3: AES 128 Bit CBC - No HMAC
- wxSQLite3: AES 256 Bit CBC - No HMAC
Use of the wxSQLite3 ciphers is not recommended for new projects. - sqleet: ChaCha20 - Poly1305 HMAC
This cipher scheme is currently the default cipher scheme. - SQLCipher: AES 256 Bit CBC - SHA1/SHA256/SHA512 HMAC
All SQLCipher variants (from version 1 up to version 4) can be accessed. - System.Data.SQLite: RC4
Supported for compatibility with earlier System.Data.SQLite versions only. Don't use it in new projects. Since early 2020 the official System.Data.SQLite distribution no longer includes the RC4 encryption extension.
In addition to reading and writing encrypted database files it is also possible to read and write plain unencrypted database files.
SQLite3 Multiple Ciphers transparently encrypts the entire database file, so that an encrypted SQLite database file appears to be white noise to an outside observer. Not only the database files themselves, but also journal files are encrypted.
For a detailed documentation of the currently supported cipher schemes, their configuration options, and the SQL interface please consult the SQLite3MultipleCiphers website.
Examples for cipher configuration
For accessing a database encrypted with the default cipher scheme specifying just the name of the database file as the Data Source and the passphrase as the Password in the connection string is sufficient:
using var connection = new SqliteConnection("Data Source=example.db;Password=Password12!");
However, for database files encrypted with a non-default cipher scheme the connection string looks a bit different. The following examples illustrate two common use cases.
How to open an existing database encrypted with SQLCipher
If you want to access a database created for example by bundle_e_sqlcipher (or any other tool supporting the original SQLCipher cipher scheme), it is necessary to configure the cipher scheme on establishing the database connection, because SQLCipher is not the default cipher scheme.
The easiest approach to accomplish this is to specify the data source in the connection string as a Uniform Resource Identifier (URI) including the required configuration parameters as URI parameters. In case of SQLCipher two configuration parameters are required:
cipher=sqlcipher
- select the SQLCipher cipher schemelegacy=4
- select the current SQLCipher version 4 (in use since November 2018)
The resulting connection string looks like this:
using var connection = new SqliteConnection("Data Source=file:example.db?cipher=sqlcipher&legacy=4;Password=Password12!");
Note:
For prior SQLCipher versions use the matching version number as the value of the legacy
parameter. For non-default SQLCipher encryption variants you may need to specify additional parameters. For a detailed list of parameters see the SQLite3 Multiple Ciphers documentation.
How to open an existing database that was encrypted with System.Data.SQLite
If you want to access a database created for example by System.Data.SQLite, it is again necessary to configure the cipher scheme on establishing the database connection.
The easiest approach to accomplish this is to specify the data source in the connection string as a Uniform Resource Identifier (URI) including the required configuration parameters as URI parameters. In case of System.Data.SQLITE RC4 one or two configuration parameters are required:
cipher=rc4
- select the System.Data.SQLITE RC4 cipher schemelegacy_page_size=<page size in bytes>
- optional, if the database uses the default SQLite page size (currently 4096 bytes); required, if a non-default page size is used.
The resulting connection string looks like this:
using var connection = new SqliteConnection("Data Source=file:example.db?cipher=rc4;Password=Password12!");
Acknowledgements
The following people have contributed to SQLite3 Multiple Ciphers NuGet:
See also
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-android31.0 is compatible. net6.0-ios was computed. net6.0-ios14.0 is compatible. net6.0-ios14.2 is compatible. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. monoandroid90 is compatible. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. xamarinios10 is compatible. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.1
- SQLitePCLRaw.lib.e_sqlite3mc (>= 2.1.7)
- SQLitePCLRaw.provider.dynamic_cdecl (>= 2.1.7)
-
.NETStandard 2.0
- SQLitePCLRaw.lib.e_sqlite3mc (>= 2.1.7)
- SQLitePCLRaw.provider.e_sqlite3mc (>= 2.1.7)
-
MonoAndroid 9.0
- SQLitePCLRaw.lib.e_sqlite3mc.android (>= 2.1.7)
- SQLitePCLRaw.provider.e_sqlite3mc (>= 2.1.7)
-
net6.0-android31.0
- SQLitePCLRaw.lib.e_sqlite3mc.android (>= 2.1.7)
- SQLitePCLRaw.provider.e_sqlite3mc (>= 2.1.7)
-
net6.0-ios14.0
- SQLitePCLRaw.lib.e_sqlite3mc (>= 2.1.7)
- SQLitePCLRaw.provider.e_sqlite3mc (>= 2.1.7)
- System.Runtime.InteropServices.NFloat.Internal (>= 6.0.1)
-
net6.0-ios14.2
- SQLitePCLRaw.lib.e_sqlite3mc.ios (>= 2.1.7)
- SQLitePCLRaw.provider.internal (>= 2.1.7)
- System.Runtime.InteropServices.NFloat.Internal (>= 6.0.1)
-
Xamarin.iOS 1.0
- SQLitePCLRaw.lib.e_sqlite3mc.ios (>= 2.1.7)
- SQLitePCLRaw.provider.internal (>= 2.1.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (4)
Showing the top 4 popular GitHub repositories that depend on SQLitePCLRaw.bundle_e_sqlite3mc:
Repository | Stars |
---|---|
dotnet/efcore
EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
|
|
uholeschak/ediabaslib
.NET BMW and VAG Ediabas interpreter library
|
|
ericsink/SQLitePCL.raw
A Portable Class Library (PCL) for low-level (raw) access to SQLite
|
|
dotnet/dotnet
Home of .NET's Virtual Monolithic Repository which includes all the code needed to build the .NET SDK from source
|
Version | Downloads | Last updated |
---|---|---|
2.1.10 | 3,206 | 9/11/2024 |
2.1.10-pre20240828193256 | 88 | 8/28/2024 |
2.1.9 | 2,569 | 8/7/2024 |
2.1.8 | 6,491 | 2/5/2024 |
2.1.7 | 569 | 11/22/2023 |
2.1.7-pre20231117161811 | 127 | 11/17/2023 |
2.1.7-pre20231110210158 | 112 | 11/10/2023 |