Sunday, 17 September 2017

c# - Password Protect a SQLite DB. Is it possible?



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



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);


No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...