reskimulud / encrypted-datastore

Encrypted DataStore is an extension function to encrypt and decrypt data String to DataStore using Advanced Encrypted Standard algorithm.

Home Page:https://dev.reskimulud.my.id/encrypted-datastore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Publish to Maven Central  Maven Central  License  Android  Kotlin 

Encrypted DataStore

Encrypted DataStore is an extension function to encrypt and decrypt data String to DataStore using Advanced Encrypted Standard algorithm.

Installation

implementation 'io.github.reskimulud:encrypted-datastore:0.0.3'

Usage

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

License of this project is under Apache 2.0 license

About

Encrypted DataStore is an extension function to encrypt and decrypt data String to DataStore using Advanced Encrypted Standard algorithm.

https://dev.reskimulud.my.id/encrypted-datastore

License:Apache License 2.0


Languages

Language:Kotlin 100.0%