Change EncryptedStorage from class to object
This commit is contained in:
@@ -4,8 +4,8 @@ import android.content.Context
|
|||||||
import androidx.security.crypto.EncryptedSharedPreferences
|
import androidx.security.crypto.EncryptedSharedPreferences
|
||||||
import androidx.security.crypto.MasterKey
|
import androidx.security.crypto.MasterKey
|
||||||
|
|
||||||
class EncryptedStorage {
|
object EncryptedStorage {
|
||||||
private val preferencesName = "secret_keeper"
|
private const val PREFERENCES_NAME = "secret_keeper"
|
||||||
|
|
||||||
fun preferences(context: Context): EncryptedSharedPreferences {
|
fun preferences(context: Context): EncryptedSharedPreferences {
|
||||||
val masterKey: MasterKey = MasterKey.Builder(context, MasterKey.DEFAULT_MASTER_KEY_ALIAS)
|
val masterKey: MasterKey = MasterKey.Builder(context, MasterKey.DEFAULT_MASTER_KEY_ALIAS)
|
||||||
@@ -14,7 +14,7 @@ class EncryptedStorage {
|
|||||||
|
|
||||||
return EncryptedSharedPreferences.create(
|
return EncryptedSharedPreferences.create(
|
||||||
context,
|
context,
|
||||||
preferencesName,
|
PREFERENCES_NAME,
|
||||||
masterKey,
|
masterKey,
|
||||||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
||||||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class LocalPreferences(context: Context) {
|
|||||||
val LAST_READ: (String) -> String = { route -> "last_read_route_$route" }
|
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()
|
private val gson = GsonBuilder().create()
|
||||||
|
|
||||||
fun clearEncryptedStorage() {
|
fun clearEncryptedStorage() {
|
||||||
|
|||||||
Reference in New Issue
Block a user