Change EncryptedStorage from class to object

This commit is contained in:
Chemaclass 2023-03-09 20:57:53 +00:00
parent 7c94af2fb2
commit e7f814e205
2 changed files with 4 additions and 4 deletions

View File

@ -4,8 +4,8 @@ import android.content.Context
import androidx.security.crypto.EncryptedSharedPreferences
import androidx.security.crypto.MasterKey
class EncryptedStorage {
private val preferencesName = "secret_keeper"
object EncryptedStorage {
private const val PREFERENCES_NAME = "secret_keeper"
fun preferences(context: Context): EncryptedSharedPreferences {
val masterKey: MasterKey = MasterKey.Builder(context, MasterKey.DEFAULT_MASTER_KEY_ALIAS)
@ -14,7 +14,7 @@ class EncryptedStorage {
return EncryptedSharedPreferences.create(
context,
preferencesName,
PREFERENCES_NAME,
masterKey,
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM

View File

@ -29,7 +29,7 @@ class LocalPreferences(context: Context) {
val LAST_READ: (String) -> String = { route -> "last_read_route_$route" }
}
private val encryptedPreferences = EncryptedStorage().preferences(context)
private val encryptedPreferences = EncryptedStorage.preferences(context)
private val gson = GsonBuilder().create()
fun clearEncryptedStorage() {