Encrypted SQLite 3-wxsqlite3

Source: Internet
Author: User

SQLite 3 open-source Edition does not include the encryption function. It is unacceptable for a local database to have no encryption function. You only need to open the database with notepad to view the data saved in the database, security is more or less affected. One way is to encrypt the content and save it to the database. However, if you encounter a similar like or comparing the field content with the field content, this will not work. The cure is to enable native SQLite to support encryption. Fortunately, the author of SQLite has reserved interfaces for encryption and decryption, and many enthusiasts have modified the source version to add encryption functions. If you are paying attention to it, you may have read a lot about how to add encryptionArticleAt the same time, I am not very familiar with related technologies, so I will not explain how to modify the source code. Although there are a lot of articles on the Internet to teach you how to modify the source code
DLL file, or the provided dll version is too low. Here is an open-source project: wxsqlite3, which is a C ++ warpper of SQLite. It implements the encryption function of SQLite and uses AES.Algorithm. You can download the latest package here. The directory \ sqlite3 \ secure contains these directories, and the sqlite3.dll file under the aes128 directory, it is a compiled SQLite 3 DLL file encrypted with the 128-bit AES algorithm, while the directory of the AES 256 is encrypted with the 256-bit AES algorithm, and the directory of the SRC is encrypted.
SQLite 3Source code. At the same time, the wxsqlite3 project is updated quickly and you can always download a newer package. The 256-bit AES encryption algorithm will be tested starting from version 1.9.8. It is estimated that the version will be available soon.

It is easy to use. First open the database sqlite3_open, and then execute sqlite3_key before the database operation. Otherwise, an error is returned.

Sqlite3_key is the input key. If the database is encrypted, you must first execute this function and enter the correct key to perform the operation. If the database is not encrypted, if you perform database operations after executing this function, the error "the database is encrypted or not a database file" may occur.

Int sqlite3_key (sqlite3 * dB, const void * pkey, int nkey), DB indicates the database, pkey indicates the key, and nkey indicates the key length. Example: sqlite3_key (dB, "ABC", 3 );

Sqlite3_rekey is used to change the key or add or clear the key to an unencrypted database. Before changing or clearing the key, you must correctly execute sqlite3_key. After sqlite3_rekey is correctly executed, you can operate the database normally before sqlite3_close closes the database. You do not need to execute sqlite3_key.

Int sqlite3_rekey (sqlite3 * dB, const void * pkey, int nkey), same as above.

Clear the key as sqlite3_rekey (dB, null, 0 ).

Original article: http://www.cnblogs.com/hiloves/archive/2010/04/25/1719749.html

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.