.netvb.netsqlitesqlcipher

Sqlite connection string with encrypted password


I have an encrypted database using "SQLite Cipher". When I try to connect to the database using Connection string the following error message appears:

'SQL logic error Cannot use "Password" connection string property: library was not built with encryption support.'

Code With Error

Imports System.Data.SQLite
Public Class frm_projects
    Dim dtset As New SQLiteConnection("Data Source=Setting.db;Password=m;")

    Private Sub frm_projects_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            If dtset.State = ConnectionState.Closed Then
                dtset.Open()

            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Warning")
        End Try
    End Sub
End Class

Image From DB Browser sqlite Cipher


Solution

  • Source of the issue

    I assume that the actual reason for this error is the the lack of support in "legacy CryptoAPI" since System.Data.SQLite version ~1.0.113.1.

    It was done in the following commit: https://system.data.sqlite.org/index.html/info/1dd56c9fd59a10fd

    What can we do?

    1. Manually Use the last NuGet version with CryptoAPI support - 1.0.112.2.

      Notice - It must be done manually - either by editing PackageReference in csproj or by editing config.packages. the reason is that older versions are unlisted (!) from the NuGet feed: NuGet feed only shows ONE version

    2. Buy perpetual source code license for SQLite Encryption Extension (SEE) which costs one time fee of 2000$ (as of Feb 2021) - purchase link

    3. Use SQLCipher - SQLCipher is an SQLite extension that provides 256 bit AES encryption of database files - GitHub source (haven't tested it myself!)

    Data Sources