Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Android SQLite API based on SQLCipher

Octocat-spinner-32 assets Removing ICU 4.4 dat file December 28, 2011
Octocat-spinner-32 dist updates to the distribution November 29, 2011
Octocat-spinner-32 external Rebuild static openssl libraries from NDK r9c February 07, 2014
Octocat-spinner-32 jni Merge branch 'google' June 27, 2013
Octocat-spinner-32 libs Removing jar and native libs November 05, 2013
Octocat-spinner-32 res added id to textview November 02, 2011
Octocat-spinner-32 src Add char[] for password to public interface to open database connections February 07, 2014
Octocat-spinner-32 .classpath updating projects files and Makefile to use ant clean and ant release November 29, 2011
Octocat-spinner-32 .gitignore updating projects files and Makefile to use ant clean and ant release November 29, 2011
Octocat-spinner-32 .gitmodules OpenSSL submodule using https github mirror November 05, 2013
Octocat-spinner-32 .project started new Android Eclipse project February 15, 2011
Octocat-spinner-32 AUTHORS adding people to authors November 01, 2011
Octocat-spinner-32 AndroidManifest.xml Repackaging structure from info.guardianproject.* to net.sqlcipher.* February 19, 2012
Octocat-spinner-32 ICU_LICENSE add ICU license file September 22, 2012
Octocat-spinner-32 LICENSE adding license May 04, 2011
Octocat-spinner-32 Makefile Fix build when using Android NDK >= r9 November 29, 2013
Octocat-spinner-32 README.org Update version support text February 10, 2014
Octocat-spinner-32 SQLCIPHER_LICENSE adding license May 04, 2011
Octocat-spinner-32 build-openssl-libraries.sh Fix to use NDK r9c to build standalone toolchain February 07, 2014
Octocat-spinner-32 proguard-project.txt Update supported versions September 26, 2013
Octocat-spinner-32 project.properties The android update project command is now renaming the properties file December 28, 2011
README.org

Download Source and Binaries

The latest binary packages for developers, with the jar’s, .so’s and a quick sample can be here, the source can be found here.

Compatibility

SQLCipher for Android runs on Android 2.1 - 4.4, both x86 and ARM architectures.

An Illustrative Terminal Listing

A typical SQLite database in unencrypted, and visually parseable even as encoded text. The following example shows the difference between hexdumps of a standard SQLite db and one implementing SQLCipher.

 ~ sjlombardo$ hexdump -C sqlite.db
 00000000 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 |SQLite format 3.|
 …
 000003c0 65 74 32 74 32 03 43 52 45 41 54 45 20 54 41 42 |et2t2.CREATE TAB|
 000003d0 4c 45 20 74 32 28 61 2c 62 29 24 01 06 17 11 11 |LE t2(a,b)$…..|
 …
 000007e0 20 74 68 65 20 73 68 6f 77 15 01 03 01 2f 01 6f | the show…./.o|
 000007f0 6e 65 20 66 6f 72 20 74 68 65 20 6d 6f 6e 65 79 |ne for the money|
 
 ~ $ sqlite3 sqlcipher.db
 sqlite> PRAGMA KEY=’test123′;
 sqlite> CREATE TABLE t1(a,b);
 sqlite> INSERT INTO t1(a,b) VALUES (‘one for the money’, ‘two for the show’);
 sqlite> .quit
 
 ~ $ hexdump -C sqlite.db
 00000000 84 d1 36 18 eb b5 82 90 c4 70 0d ee 43 cb 61 87 |.?6.?..?p.?C?a.|
 00000010 91 42 3c cd 55 24 ab c6 c4 1d c6 67 b4 e3 96 bb |.B?..?|
 00000bf0 8e 99 ee 28 23 43 ab a4 97 cd 63 42 8a 8e 7c c6 |..?(#C??.?cB..|?|
 
 ~ $ sqlite3 sqlcipher.db
 sqlite> SELECT * FROM t1;
 Error: file is encrypted or is not a database

(example courtesy of SQLCipher)

Details for Developers

We’ve packaged up a very simple SDK for any Android developer to add SQLCipher into their app with the following three steps:

  1. Add a single sqlcipher.jar and a few .so’s to the application libs directory
  2. Update the import path from android.database.sqlite.* to net.sqlcipher.database.* in any source files that reference it. The original android.database.Cursor can still be used unchanged.
  3. Init the database in onCreate() and pass a variable argument to the open database method with a password:
 SQLiteDatabase.loadLibs(this); //first init the db libraries with the context
 SQLiteOpenHelper.getWritableDatabase("thisismysecret"):

An article covering both integration of SQLCipher into an Android application as well as building the source can be found here.

Notepad + SQLCipher = Notepadbot

Notepadbot is a sample application pulled from the standard Android samples code and updated to use SQLCipher. You can browse the source here and download the apk here.

Building

In order to build android-database-sqlcipher from source you will need both the Android SDK as well as Android NDK. Once you have cloned the repo, change directory into the root of the repository and run the following commands:

 # this only needs to be done once
 make init
 # to build the source
 make

Recursively copy the libs directory into the root of your application, you will also need the assets directory copied into the root of your application folder. A detailed set of instructions and further customization can be found here.

License

The Android support libraries are licensed under Apache 2.0, in line with the Android OS code on which they are based. The SQLCipher code itself is licensed under a BSD-style license from Zetetic LLC. Finally, the original SQLite code itself is in the public domain.

Something went wrong with that request. Please try again.