SQLite with encryption/password protection

2018-12-31 17:25发布

I'm just learning to use SQLite and I was curious if such is possible:

  1. Encryption of the database file?

  2. Password protect opening of the database?

PS. I know that there is this "SQLite Encryption Extension (SEE).", but according to the documentation, "The SEE is licensed software...." and "The cost of a perpetual source code license for SEE is US $2000."

11条回答
骚的不知所云
2楼-- · 2018-12-31 17:57

The .net library System.Data.SQLite also provides for encryption.

查看更多
路过你的时光
3楼-- · 2018-12-31 17:58

For projects using Javascript, the package written by journeyapps works seamlessly.

https://github.com/journeyapps/node-sqlcipher

It worked on Mac/Windows/Linux for me. It compiles SQLCipher on your platform. There is no need to pay for the licenses from Zetetic.

查看更多
明月照影归
4楼-- · 2018-12-31 18:13

You can password protect SQLite3 DB. For the first time before doing any operations, set password as follows.

SQLiteConnection conn = new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;");
conn.SetPassword("password");
conn.open();

then next time you can access it like

conn = new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;Password=password;");
conn.Open();

This wont allow any GUI editor to view Your data. Later if you wish to change the password, use conn.ChangePassword("new_password"); To reset or remove password, use conn.ChangePassword(String.Empty);

查看更多
听够珍惜
5楼-- · 2018-12-31 18:13

You can always encrypt data on the client side. Please note that not all of the data have to be encrypted because it has a performance issue.

查看更多
琉璃瓶的回忆
6楼-- · 2018-12-31 18:15

You can get sqlite3.dll file with encryption support from http://system.data.sqlite.org/.

1 - Go to http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki and download one of the packages. .NET version is irrelevant here.

2 - Extract SQLite.Interop.dll from package and rename it to sqlite3.dll. This DLL supports encryption via plaintext passwords or encryption keys.

The mentioned file is native and does NOT require .NET framework. It might need Visual C++ Runtime depending on the package you have downloaded.

UPDATE

This is the package that I've downloaded for 32-bit development: http://system.data.sqlite.org/blobs/1.0.94.0/sqlite-netFx40-static-binary-Win32-2010-1.0.94.0.zip

查看更多
有味是清欢
7楼-- · 2018-12-31 18:15

Yes, it's possible. If targeting .Net Standard 4.6.1+ or Core, I think a fairly straightforward to get Sqlite encryption is to use Microsoft.Data.Sqlite per my answer here.

查看更多
登录 后发表回答