Compile System.Data.Sqlite With AES256

前端 未结 1 1214
轻奢々
轻奢々 2021-01-16 06:56

I\'m knee deep in compilation for sqlite, system.data.sqlite, and xerial\'s JDBC trying to get an encrypted sqlite file working through all three. From my understanding,

1条回答
  •  梦毁少年i
    2021-01-16 07:39

    If you're targeting .NET standard 4.6.1+ or Core, you may want to give Microsoft.Data.Sqlite a try. This can give you AES256 encryption by simply adding 2 Nuget Packages. By the way, there are paid options to get AES256 compiled System.Data.Sqlite. Some are listed in this answer.

    If your project is currently using System.Data.Sqlite, then transitioning will involve some search/replace of method & class names, much of which is a difference in caps. For example, "SQLiteDataReader" becomes "SqliteDataReader."

    Another difference is that Microsoft.Data.Sqlite is strict about column naming. For example, a command that references a column named "DateListed" will fail if the database schema has that column as "Datelisted."

    If you want to explore making a transition install 2 nuget packages:

    Install-Package Microsoft.Data.Sqlite.Core
    Install-Package SQLitePCLRaw.bundle_sqlcipher
    

    Setup SQLitePCL

    SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlcipher());
    SQLitePCL.Batteries_V2.Init();
    SQLitePCL.raw.FreezeProvider();
    

    Create encrypted database

    string error = string.Empty;
    static SQLitePCL.sqlite3 sqlite
    SQLitePCL.raw.sqlite3_open(dbPath, out sqlite);
    SQLitePCL.raw.sqlite3_exec(sqlite, "PRAGMA key ='myPassword'", out error);
    SQLitePCL.raw.sqlite3_close(sqlite);
    

    0 讨论(0)
提交回复
热议问题