Password Protect a SQLite DB. Is it possible?

Jhonny D. Cano -Leftware- picture Jhonny D. Cano -Leftware- · Sep 4, 2009 · Viewed 174.2k times · Source

I have to face a new little project. It will have about 7 or 9 tables, the biggest of them will grow by a max rate of 1000 rows a month.

I thought about SQLite as my db... But i will need to protect the db in case anybody wants to change data from the db

My main question is:

Is it possible password protect a sqlite db as you would do on access?

What other RDBMS would you recommend for such a small solution?

The development would be on C#, but i'm searching something free.

Answer

Mangesh picture Mangesh · Jun 22, 2014

You can password protect a SQLite3 DB. Before doing any operations, set the 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. Some editors can decrypt the DB if you provide the password. The algorithm used is RSA.

Later if you wish to change the password, use

conn.ChangePassword("new_password");

To reset or remove password, use

conn.ChangePassword(String.Empty);