russhwolf / multiplatform-settings

A Kotlin Multiplatform library for saving simple key-value data
Apache License 2.0
1.7k stars 67 forks source link

Added KeystoreSettings for secure storage on Android #107

Closed GusWard closed 2 years ago

GusWard commented 2 years ago

Enable secure storage of data in shared preferences on Android, using Keystore to store cryptographic keys and cipher for encryption.

KeystoreSettings has the same API as AndroidSettings for simplicity of use, it also uses AndroidSettings internally to store the encrypted data as this is already tried and tested.

russhwolf commented 2 years ago

Does this have any advantage over using EncryptedSharedPreferences with AndroidSettings? I'd prefer not to maintain a new implementation if there's a well-supported alternative.

GusWard commented 2 years ago

Does this have any advantage over using EncryptedSharedPreferences with AndroidSettings? I'd prefer not to maintain a new implementation if there's a well-supported alternative.

Yeah I agree, we are actually looking in to doing it that way aswell so this might change direction a bit, we will potentially have problems as EncryptedSharedPreferences isnt supported in SDK < 21.

How do you feel about bumping that minSdk version?

russhwolf commented 2 years ago

There shouldn't be any need to bump minsdk because this library doesn't need to ship the integration. You can already do something like this:

val preferences = EncrpytedSharedPreferences.create(...)
val settings = AndroidSettings(preferences)
GusWard commented 2 years ago

Closing this as we are just passing in an instance of encrypted shared preferences in our consumer library 👍