![](/img/trans.png)
[英]Encrypt login and password in sqlite database - SHA 256 in C#
[英]Can i password encrypt SQLite database?
我使用SQLite數據庫版本3與C#Windows應用程序..我想使用密碼或任何其他加密方式加密SQLite數據庫文件,以防止客戶端從程序文件文件夾中打開它。
我不想要任何運行時加密方式,我只想在客戶端嘗試從程序文件中打開它時使數據庫文件顯示密碼字段..謝謝
編輯
如果我從代碼加密它,客戶端可以在安裝完成后打開它並將db文件傳輸到程序文件,然后再打開程序執行加密不是嗎?
我使用SQLite版本3完美運行! 你必須這樣做:
//if the database has already password
try{
string conn = @"Data Source=database.s3db;Password=Mypass;";
SQLiteConnection connection= new SQLiteConnection(conn);
connection.Open();
//Some code
connection.ChangePassword("Mypass");
connection.Close();
}
//if it is the first time sets the password in the database
catch
{
string conn = @"Data Source=database.s3db;";
SQLiteConnection connection= new SQLiteConnection(conn);
connection.Open();
//Some code
connection.ChangePassword("Mypass");
connection.Close();
}
此后如果用戶試圖打開數據庫。 會說管理員受保護或者數據庫是加密的,還是不是數據庫或損壞的文件!
在這個論壇發現一個帖子表明..
Standard SQLite3 API doesn't offer any form of protection and relies only on underlying OS privileges mecanism (if any) for "security". If you have an existing SQLite-style database which uses a specific API to gain access, then you should use this particular (non-standard) API.
如果您可以/想要為SQLite使用某種擴展,您還可以嘗試SQLite加密擴展(SEE)或SQLite Crypt
但您可以使用SQLite.Data更改/設置數據庫的密碼,如本文所示。
嘗試使用sqlitestudio.pl
作為編輯器。
對於Database Type,在連接時選擇System.Data.SQLite
。
不幸的是,SQlite文件中的密碼只能從代碼中添加或刪除或更改。 為此,您需要System.Data.SQLite
命名空間,它將為您提供方法以及適配器和連接。
您可以使用sq-lite
.net提供程序(System.Data.SQLite)的內置加密。 試試這個:
http://sqlite.phxsoftware.com/forums/t/130.aspx 在此處輸入鏈接說明
或使用:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.