Encrypted DataStore is an extension function to encrypt and decrypt data String to DataStore using Advanced Encrypted Standard algorithm.
implementation 'io.github.reskimulud:encrypted-datastore:0.0.3'
AES Builder
val aes: AES = AES.Builder()
.setKey("your_cipher_key") // 256-bit
.setIv("your_initialize_vector") // 128-bit
.build()
To store using secureEdit(aes: AES, defaultValue: String)
method, and use secureMap(value: String, aes: AES)
to retrieve data from DataStore
// to store data
suspend fun setEmail(email: String) =
dataStore.data.secureEdit(aes, DEDAULT_FALUE) {
it[EMAIL_KEY] ?: DEFAULT_VALUE
}
// to retrieve data
fun getEmail(): Flow<String> =
dataStore.secureMap(value, aes) { preference, encryptedValue ->
preference[EMAIL_KEY] = encryptedValue
}
License of this project is under Apache 2.0
license