Enabling Database Encryption with ForestDB

As written in the previous post, Enabling ForestDB for CBL Android, since version 1.2.0, Couchbase Lite supports ForestDB as a storage type. In addition, ForestDB storage supports 256-bit AES encryption. This post explains how to enable database encryption with ForestDB.

About ForestDB, please read the previous post, Enabling ForestDB for CBL Android.

Installing ForestDB module:

ForestDB is a optional. It is not part of default dependencies of couchbase-lite-android. You needs to add forestdb as a dependency in the application level build.gradle file. As forestdb module supports the encryption feature, it does not require any additional module for the encryption feature.

dependencies {
  compile 'com.couchbase.lite:couchbase-lite-android:1.2.1'
  compile 'com.couchbase.lite:couchbase-lite-android-forestdb:1.2.1'

How to enable the encryption with ForestDB:

By opening the database with the database key, CBL autotamtically opens the database with ForestDB storage with AES 256bit encryption. Please specify the database key (password) with using DatabaseOptions.

String KEY_4_DATABASE = "<password>";

DatabaseOptions options = new DatabaseOptions();
database = manager.openDatabase(DATABASE_NAME, options);


  • By specifiying database key, attachments are also enctypted by 256-bit AES encryption.

Sample App:

Please refer GrocerySync-Android ForestDB with Encryption branch as a sample Android application.

Written on May 10, 2016