mirror of https://github.com/x13a/Wasted.git
move authentication code to secure store
This commit is contained in:
parent
089cec82f1
commit
33d872d560
|
@ -10,8 +10,8 @@ android {
|
|||
applicationId "me.lucky.wasted"
|
||||
minSdk 25
|
||||
targetSdk 31
|
||||
versionCode 3
|
||||
versionName "1.0.2"
|
||||
versionCode 4
|
||||
versionName "1.0.3"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
@ -45,4 +45,5 @@ dependencies {
|
|||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
|
||||
implementation 'androidx.preference:preference-ktx:1.1.1'
|
||||
implementation 'androidx.security:security-crypto:1.0.0'
|
||||
}
|
|
@ -3,15 +3,23 @@ package me.lucky.wasted
|
|||
import android.content.Context
|
||||
|
||||
import androidx.core.content.edit
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.security.crypto.EncryptedSharedPreferences
|
||||
import androidx.security.crypto.MasterKeys
|
||||
|
||||
class Preferences(context: Context) {
|
||||
class Preferences(ctx: Context) {
|
||||
companion object {
|
||||
private const val SERVICE_ENABLED = "service_enabled"
|
||||
private const val CODE = "code"
|
||||
}
|
||||
|
||||
private val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
private val mk = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
|
||||
private val prefs = EncryptedSharedPreferences.create(
|
||||
"s_shared_prefs",
|
||||
mk,
|
||||
ctx,
|
||||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
||||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM,
|
||||
)
|
||||
|
||||
var isServiceEnabled: Boolean
|
||||
get() = prefs.getBoolean(SERVICE_ENABLED, false)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
move authentication code to secure store
|
Loading…
Reference in New Issue