Sqlite數據庫加密加密

Sqlite數據庫加密。(C#鏈接加密的Sqlite數據庫的方法)

參考地址[1]: https://www.jb51.net/article/120279.htm
sqlite破解安裝包下載: https://download.csdn.net/download/yinchoushi8780/11170781javascript

1、數據庫加密

對數據加密分兩種,一種是對數據庫自己進行加密,另外一種是對數據表中的數據進行加密,
若是SQLite數據庫加密,我這裏使用的一個管理工具叫SQLiteDeveloper,以下就能夠加密數據庫。
在這裏插入圖片描述
若是在工具中不提供密碼的狀況下打開數據庫,會給你錯誤提示以下:
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述java

2、C#代碼鏈接數據庫

或者在C# 使用錯誤的密碼也會給你錯誤提示:
System.Data.SQLite.SQLiteException:「file is encrypted or is not a database
在這裏插入圖片描述
正確的鏈接方式就是在鏈接字符串中提供正確的密碼:web

using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenSqliteDBByPwd
{
  class Program
  {
    static void Main(string[] args)
    {
      string DB_PATH = "Data Source=EncryptedDB.db3; Password=1111";
      using (SQLiteConnection con = new SQLiteConnection(DB_PATH))
      {
        con.Open();
        string sqlStr = @"INSERT INTO Customer(CUST_NO,CUSTOMER)
                 VALUES
                 (
                   3001,
                   'Allen'
                 )";
        using (SQLiteCommand cmd = new SQLiteCommand(sqlStr, con))
        {
          cmd.ExecuteNonQuery();
        }
      }
    }
  }
}

參考地址[1]: https://www.jb51.net/article/120279.htm
sqlite破解安裝包下載: https://download.csdn.net/download/yinchoushi8780/11170781sql