Skip to content

Commit a632470

Browse files
Merge pull request #59 from Web3Auth/bump-session-manager-sdk
bump library deps
2 parents 3ee92e9 + a73fcc2 commit a632470

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ dependencies {
6868
implementation 'org.web3j:core:4.8.8-android'
6969

7070
//session-manager-sdk
71-
implementation 'com.github.Web3Auth:session-manager-android:0.0.3'
71+
implementation 'com.github.Web3Auth:session-manager-android:0.0.5'
7272

7373
// Test
7474
testImplementation 'junit:junit:4.+'

core/src/main/java/com/web3auth/core/keystore/KeyStoreManagerUtils.kt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,20 @@ object KeyStoreManagerUtils {
8282
fun decryptData(key: String): String? {
8383
var result: String? = null
8484
try {
85-
val sharedPreferenceIds = sharedPreferences.all
86-
sharedPreferenceIds.forEach {
87-
if (it.key.contains(key)) {
88-
result = sharedPreferences.getString(it.key, "")
85+
if (this::sharedPreferences.isInitialized) {
86+
val sharedPreferenceIds = sharedPreferences.all
87+
sharedPreferenceIds.forEach {
88+
if (it.key.contains(key)) {
89+
result = sharedPreferences.getString(it.key, "")
90+
}
8991
}
92+
if (result == null) return null
93+
val encryptedPairData = result?.let { getEncryptedDataPair(it) }
94+
val cipher = Cipher.getInstance(TRANSFORMATION)
95+
val keySpec = IvParameterSpec(encryptedPairData?.first)
96+
cipher.init(Cipher.DECRYPT_MODE, getKey(), keySpec)
97+
return cipher.doFinal(encryptedPairData?.second).toString(UTF_8)
9098
}
91-
if (result == null) return null
92-
val encryptedPairData = result?.let { getEncryptedDataPair(it) }
93-
val cipher = Cipher.getInstance(TRANSFORMATION)
94-
val keySpec = IvParameterSpec(encryptedPairData?.first)
95-
cipher.init(Cipher.DECRYPT_MODE, getKey(), keySpec)
96-
return cipher.doFinal(encryptedPairData?.second).toString(UTF_8)
9799
} catch (ex: Exception) {
98100
ex.printStackTrace()
99101
}

0 commit comments

Comments
 (0)