C # Access an encrypted SQLite database

Source: Internet
Author: User
Tags sqlite 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:

1 stringDb_path ="Data source=f:/sqlitedb/test.db; Password=123";2 3         Private voidAdd_click (Objectsender, RoutedEventArgs e)4         {    5             using(Sqliteconnection con =Newsqliteconnection (db_path))6             {7 con. Open ();8                 stringSqlstr =@"INSERT into Hero9 VALUESTen                                   ( One 3, A ' test effective ' -                                   )"; -                 using(Sqlitecommand cmd =NewSqlitecommand (Sqlstr, con)) the                 { - cmd. ExecuteNonQuery (); -                 } -             } +}
View Code

C # Access an 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.