In This Topic
The SQLiteCrypt is an add-on to the public domain version of SQLite that adds transparent AES 256 encryption support for SQLite. dotConnect for SQLite fully supports connecting to SQLiteCrypt encrypted databases, however it does not provide the SQLiteCrypt extension itself. In order to use SQLiteCrypt encryption you need to buy SQLiteCrypt separately.
To connect to SQLiteCrypt encrypted database, you should set the Encryption connection string parameter to SQLiteCrypt and specify the Password and Encryption License Key connection string parameters. To change the database password use the ChangePassword method of SQLiteConnection. To decrypt the database, assign an empty password to it.
Here is an example of using dotConnect for SQLite with an SQLiteCrypt encrypted database.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Devart.Data.SQLite;
namespace SQLiteCryptSample
{
class Program
{
static void Main(string[] args)
{
// Open/create an unencrypted database
SQLiteConnection conn = new SQLiteConnection("Data Source=database.db;Encryption=SQLiteCrypt; Encryption License Key=00000-000-0000000-00000; FailIfMissing = false;");
conn.Open();
conn.ChangePassword("best"); // Encrypt the database with the password "best"
conn.Close();
// Open the already encrypted database
conn = new SQLiteConnection("Data Source=database.db;Encryption=SQLiteCrypt; Encryption License Key=00000-000-0000000-00000; FailIfMissing = false; password=best");
conn.Open();
conn.ChangePassword("best2"); // Change password to "best2"
conn.Close();
// Open the database with the new password
conn = new SQLiteConnection("Data Source=database.db;Encryption=SQLiteCrypt; Encryption License Key=00000-000-0000000-00000; FailIfMissing = false; password=best2");
conn.Open();
conn.ChangePassword(""); // Assign an empty password - decrypt the database
conn.Close();
// Open the unencrypted database
conn = new SQLiteConnection("Data Source=database.db; FailIfMissing = false;");
conn.Open();
}
}
}
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports Devart.Data.SQLite
Namespace SQLiteCryptSample
Class Program
Private Shared Sub Main(args As String())
' Open/create an unencrypted database
Dim conn As New SQLiteConnection("Data Source=database.db;Encryption=SQLiteCrypt; Encryption License Key=00000-000-0000000-00000; FailIfMissing = false;")
conn.Open()
conn.ChangePassword("best")
' Encrypt the database with the password "best"
conn.Close()
' Open the already encrypted database
conn = New SQLiteConnection("Data Source=database.db;Encryption=SQLiteCrypt; Encryption License Key=00000-000-0000000-00000; FailIfMissing = false; password=best")
conn.Open()
conn.ChangePassword("best2")
' Change password to "best2"
conn.Close()
' Open the database with the new password
conn = New SQLiteConnection("Data Source=database.db;Encryption=SQLiteCrypt; Encryption License Key=00000-000-0000000-00000; FailIfMissing = false; password=best2")
conn.Open()
conn.ChangePassword("")
' Assign an empty password - decrypt the database
conn.Close()
' Open the unencrypted database
conn = New SQLiteConnection("Data Source=database.db; FailIfMissing = false;")
conn.Open()
End Sub
End Class
End Namespace