- this library gives you an out of the box solution for encrypting values in a Shared Preferences file via the Android Keystore
- no need to worry about managing/generating keys in your app, just plug'n'play
- Minimum of API 21 (Android Lollipop), approximately 85% of all devices
- All the requirements of what the Android Keystore requires
- uses
com.android.support.appcompat
(androidX is coming in the future!)
- it's a very small library with very few dependencies
- Comparatively Armadillo is a really good library, and really feature rich. But you might not use all of those features, and it would bulk up your app
- The AndroidX SDK Team will be releasing their EncryptedSharedPreferences, it's currently in alpha, and I expect it to eventually replace this repo
- the API for this library matches the API for AndroidX's library, so when it's ready you could switch to using this with minimal friction
- here's AndroidX's source
- everything the
android.content.SharedPreferences
does with an added layer of encryption on top - the encryption under the hood relies on the Keystore (so your keys are mostly managed by the OS keystore process1)
val prefs = EncryptedSharedPreferences.create(filename = "default", context)
val editor = prefs.edit()
editor.putString("KEY", "value")
editor.apply()
prefs.getString("KEY", "default value")
- replace support libs with androidx
- introduce a mechanism for migrating from current shared prefs, to androidx shared prefs
- perhaps some instrumentation tests?
- for below API 23 (Android Marshmallow), Symmetric Encryption is not supported out of the box. A key is generated, and stored in shared preferences (asymmetrically encrypted)