CentOS PHP sqlite3 support database encryption via Sqlcipher compilation

Source: Internet
Author: User
Tags php sqlite3 sqlite database
recently, because of project needs, the server-side generated SQLite to encrypt. Server backend is written by PHP, the operating system is CentOS. The open source Sqlite3 reserves the database encryption interface, but it is not implemented. so found on the Internet sqlcipher, it sqlite3 the implementation of the unencrypted encryption, and can be recompiled by recompiling php sqlite3 extension, to support the SQLite database encryption.

Specific operation, can refer to the steps of the official website, address: https://www.zetetic.net/sqlcipher/sqlcipher-for-php/

The operation of the official website, the system is used by Ubuntu, where the corresponding commands can be converted to CentOS under the use of the. You can compile the procedure by referring to the official website.

After the compilation is successful, sqlite3.so will be generated and replaced directly with the previous server PHP extension sqlite3.so (preferably a backup before replacement). After the replacement is complete, restart the Apache server,

To test and test the code:

Create a test.sqlite file with a password of 12345678 and a parameter of 6 to open it without creating it. Specific information can be viewed in reference to the source file sqlite3.c

$db =new Sqlite3 ("Test.sqlite", 6, "12345678");

$db->exec ("CREATE table mytest (name varchar (200))");

$db->exec ("INSERT into mytest (name) VALUES (' AAAA ')");

$result = $db->query (' SELECT * from mytest ');

print_f ( $result );

?>

If you can print out the results, the SQLITE3 has been recompiled successfully. This is basically a success, but you still need to check to see if the generated database is encrypted. You can use the generated test.sqlite to open some of your own tools before you try, Errors are usually prompted. This time the description has been successfully encrypted to SQLite.

By the way, there are also support steps for Android and iOS on the official website, which can be viewed on the official website.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The above describes the CentOS under the PHP through Sqlcipher compiled sqlite3 support database encryption, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.