SQLite database--c# access to encrypted SQLite database

Source: Internet
Author: User
Tags sqlite database string format sqlite manager



Premise: A project needs to store various password data, using the embedded SQLite database. The default SQLite database is not encrypted, which is quite unsafe. Look for ways to find a way ...



Method:



1. Encrypted using the SQLite manager.



Some SQLite managers have encryption capabilities for the SQLite database. This side dish is used by: SQLite Developer Management tool. The encryption is as follows:






The password is set to OK.



2.c# accessing the SQLite database with passwords



First of all, SQLite does not have a password to access the string format, just write to the database where the path can be:



String connstr= "Data source=f:/sqlitedb/test.db";



Access with password for more complex, the result is simple, add password parameters can:



String connstr= "Data source=f:/sqlitedb/test.db; Password=123 ";






Sample code, pro-Test valid:


string DB_PATH = "Data Source = F: /sqlitedb/test.db; Password = 123";

         private void add_Click (object sender, RoutedEventArgs e)
         {
             using (SQLiteConnection con = new SQLiteConnection (DB_PATH))
             {
                 con.Open ();
                 string sqlStr = @ "INSERT INTO hero
                                   VALUES
                                   (
                                       3,
                                       ‘Test works’
                                   ) ";
                 using (SQLiteCommand cmd = new SQLiteCommand (sqlStr, con))
                 {
                     cmd.ExecuteNonQuery ();
                 }
             }
         } 





SQLite database--c# access to encrypted SQLite database


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.