How to use Cipher in Xamarin Forms with package sqlite-net-pcl


#1

Hi,

I need help on how to implement the SQLcipher feature in a Xamarin.Forms application for android and iOS.

I am using the package “sqlite-net-pcl”, “sqlite-net-sqlcipher” and “SQLitePCLRaw.bundle_sqlcipher”, implementing, informing a key has been defined, and when accessing the file in DB Browser for SQLite, the file is accessible and nothing was cryptographed.

Code used to access SQLite in the shared project:

public class SMBDbContext
{

    private static SMBDbContext instance;
    public static SMBDbContext Instance
    {
        get
        {
            if (instance == null)
            {
                instance = new SMBDbContext();
            }

            return instance;
        }
    }

    public SQLiteConnection Connection;

    public static string DataBasePath { get; set; } = string.Empty;

    public SMBDbContext()
    {
        var location = "smb.db3";
        location = System.IO.Path.Combine(DataBasePath, location);
        Connection = new SQLiteConnection(location);
        Connection.SetKey("criptotest2asdasd");
    }

Packges version:

"sqlite-net-pcl": "1.4.118",
"sqlite-net-sqlcipher": "1.5.176-beta",
"SQLitePCLRaw.bundle_sqlcipher": "1.1.9"