I'm using a .NET Core project in order to manage SQLite db encrypted and I would be able to create a db copy programmatically without encryption, but I'm not finding any sample code and I don't even know if this is possible.
I'm starting from scratch with the following project: https://github.com/paragpkulkarni/SQLiteEncryptionUsingEFCore
This is the final solution:
void DecryptDB(string sourceFilename, string destinationFilename, string password)
{
var connectionString = new SqliteConnectionStringBuilder
{
DataSource = sourceFilename,
Mode = SqliteOpenMode.ReadWriteCreate,
Password = password
};
using var cn = new SqliteConnection(connectionString.ToString());
cn.Open();
using var c = cn.CreateCommand();
c.CommandText = @$"ATTACH DATABASE '{destinationFilename}' AS plaintext KEY '';";
var r = c.ExecuteNonQuery();
c.CommandText = @"SELECT sqlcipher_export('plaintext')";
r = c.ExecuteNonQuery();
}