Android database (sqlite) encryption solution, androidsqlite

Source: Internet
Author: User

Android database (sqlite) encryption solution, androidsqlite

Recently, due to the security of some projects, you need to encrypt the database. The first thought is to encrypt the database through AES and then decrypt the database at runtime. The other is to encrypt the content in the database.

Soon these two solutions are not ideal. The first method of encryption is the same as the false one. The second method is difficult if the encrypted field is used to search for data.

Therefore, the third solution is to decrypt data in the memory. SQLITE is encrypted on the Internet. Therefore, SQLITE is compiled to support encryption step by step based on the instructions on the Internet.

The next step is how to make the SDK easy to use? The first thought was to port the native database usage method, but it was a little more difficult to do than you thought at first, but finally completed the transplantation work in the repair and repair. At first, we used the source code of the database module of Android2.2, but some problems often occur during runtime. Later, we used the source code of the database module of Android4.0 to solve these problems. Of course, at the beginning of the Android4.0 source code compilation, it is okay to run on a mobile phone above Android, but an error will be reported below android. Therefore, if you are not proud of it, move the database module of Android4.0 to the Android2.2 source code directory for compilation. Of course, you must solve the problem of both versions.

Android native does not support database encryption, so you need to use other methods to encrypt the database. This SDK is used to separately transplant the SQLITE module from the native Android4.0 source code and add the encryption method to this module during compilation, because the SQLITE Source Code contains an encrypted interface, therefore, you only need to add this pre-compiled parameter and some files during migration.

This SDK only supports Versions later than Android2.1.

Compiling environment:
Android2.2 source code
Ubuntu12.10 64-bit


1. Synchronize the source code of Android2.2 (about 4 GB capacity)
2. install necessary dependent Libraries
3. Run in the Android2.2 source code directory:

[Plain]View plain copy print?

  • $. Build/envsetup. sh



In this way, the environment can be initialized.
4. Go to the source code directory and run:[Plain]View plain copy print?

  • $ Mm

 

In this way, you can compile and generate the results in the out \ target \ product \ generic \ system \ lib \ libsqlcrypt_jni.so

I still want to generate the x86 library because there are some problems and there is no time to solve them.

Source code: https://github.com/lendylongli/android-sqlite-encrypt


In android, how does one open an encrypted sqlite database?

In ANDROID, application data is private. You can use ContentProvider to obtain data from other applications.
 
Encryption for Android Sqlite?

Does sqlite3 support login verification? However, android does not support this function. Can I compile a jni library of sqlite3 by myself and directly call this library in the program to perform database-related operations, instead of using the database operation class that comes with android?

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.