Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 通用Windows平台C中的SQLite加密#_C#_Windows 10 Universal_Pragma_Sqlite Net - Fatal编程技术网

C# 通用Windows平台C中的SQLite加密#

C# 通用Windows平台C中的SQLite加密#,c#,windows-10-universal,pragma,sqlite-net,C#,Windows 10 Universal,Pragma,Sqlite Net,我使用SQLite.Net-pclv3.1.1作为Nuget包,并使用VS扩展SQLite for UniversalWindowsPlatform 3.13.0.0。在C#和XAML中的Windows 10应用程序中: private void ConnectToDB() { var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path,

我使用SQLite.Net-pclv3.1.1作为Nuget包,并使用VS扩展SQLite for UniversalWindowsPlatform 3.13.0.0。在C#和XAML中的Windows 10应用程序中:

  private  void ConnectToDB()
    {
        var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "persons.sqlite");

        using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), sqlpath))
        {
            var res = conn.Execute("PRAGMA key = 'mypass'");

            conn.CreateTable<Person>();
            conn.Insert(Person.NewPersion());
        }
    }

    public class Person
    {
        public static Person NewPersion()
        {
            return new Person() { Uuid = Guid.NewGuid().ToString(), Name = "John", Age = 12 };
        }

        [PrimaryKey]
        public string Uuid { get; set; }
        public string Name { get; set; }
        public int Age { get; set; }
    }
奇怪的是,3个月前,我成功地打开了一个数据库,却没有使用PRAGMA键抛出:

'file is encrypted or is not a database'
这很完美,因为数据库是加密的。事实上,试图从SqliteExplorer打开在Windows10中生成的DB会抛出这个错误

我需要能够像以前一样加密数据库,尝试下载以前的扩展库和Nuget库,但没有成功。有人用这段代码加密sqlite数据库吗


关于。

如果我们按照文件。有任意数量的SQLite扩展提供加密,这些扩展可能使用也可能不使用此pragma。似乎是其中之一;这可能是你上次用的,也可能不是。
'file is encrypted or is not a database'