This is a lightweight library to generate a 64-bit random key and using AES Algorithm to encrypt/decrypt that random number to get a Secret Key and save it to Key Store.

This library especially supports for Realm Encryption. That means when using you don17;t have to care about how to get a random key, where to save that key for safe,30; this library will take it.

Support all

Setup and using

  1. Add library to your build.gradle in app level
compile 'com.github.tntkhang:realm-encryption-helper:1.0.0'

2.In your CustomeApplication where you init your Realm

// Config RealmEncryptionHelper
RealmEncryptionHelper realmEncryptionHelper = RealmEncryptionHelper.initHelper(this, getString(R.string.app_name));

// Config Realm
RealmConfiguration config = new RealmConfiguration.Builder()
         .encryptionKey(realmEncryptionHelper.getEncryptKey()) // Call realmEncryptionHelper to get encrypt key

with this code


The library will check and generate a new key if your app doesn’t contain the key in Key Store before and then save it to Key Store, otherwise, it will be got from Key Store.


Download and run project for simple demo

That is, let’s enjoy!

Source link


Please enter your comment!
Please enter your name here