Skip to content

Commit

Permalink
Merge pull request #647 from DKU-Dgaja/dev
Browse files Browse the repository at this point in the history
Merge Dev -> Main
  • Loading branch information
saesang authored Nov 8, 2024
2 parents 311a01c + 131bfcc commit e5b5dc4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions android/gitudy/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ android {
applicationId = "com.takseha.gitudy"
minSdk = 24
targetSdk = 34
versionCode = 6
versionName = "v1.0.4"
versionCode = 7
versionName = "v1.0.5"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.takseha.data.sharedPreferences

import android.content.Context
import android.content.SharedPreferences
import android.util.Log
import androidx.security.crypto.EncryptedSharedPreferences
import androidx.security.crypto.MasterKey
import javax.crypto.AEADBadTagException

class SP(context: Context){
private val prefs: SharedPreferences by lazy {
Expand All @@ -21,10 +23,27 @@ class SP(context: Context){
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)
} catch (e: Exception) {
throw RuntimeException("Error initializing EncryptedSharedPreferences", e)
Log.e("SP", "Error 발생: ${e.message}. SP 초기화")
clearPref(context)

// SP 재생성
EncryptedSharedPreferences.create(
context.applicationContext,
"encrypted_shared_prefs",
MasterKey.Builder(context.applicationContext, MasterKey.DEFAULT_MASTER_KEY_ALIAS)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build(),
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)
}
}

private fun clearPref(context: Context) {
context.getSharedPreferences("encrypted_shared_prefs", Context.MODE_PRIVATE)
.edit().clear().apply()
}

fun savePref(spKey: String, spValue: String) {
prefs.edit().putString(spKey, spValue).apply()
}
Expand Down

0 comments on commit e5b5dc4

Please sign in to comment.