mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-14 02:01:56 +00:00
fix crash on initial launch
This commit is contained in:
parent
d9f9d4b7da
commit
23484e1e09
2 changed files with 11 additions and 5 deletions
|
|
@ -150,7 +150,7 @@ android {
|
|||
buildConfigField "String", "TESTING_LEVEL", "\"production\""
|
||||
multiDexEnabled true
|
||||
|
||||
versionCode 2161
|
||||
versionCode 2165
|
||||
versionName "1.10"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ constructor(ctx: Context, var sharedPreferences: SharedPreferences, var keyStore
|
|||
|
||||
|
||||
@Throws(NoSuchAlgorithmException::class, NoSuchPaddingException::class, NoSuchProviderException::class, BadPaddingException::class, IllegalBlockSizeException::class, UnsupportedEncodingException::class)
|
||||
fun decrypt(encrypted: String): String {
|
||||
fun decrypt(encrypted: String): String? {
|
||||
val c: Cipher
|
||||
val publicIV = getRandomIV()
|
||||
|
||||
|
|
@ -180,9 +180,15 @@ constructor(ctx: Context, var sharedPreferences: SharedPreferences, var keyStore
|
|||
|
||||
}
|
||||
|
||||
val decodedValue = Base64.decode(encrypted.toByteArray(charset("UTF-8")), Base64.DEFAULT)
|
||||
val decryptedVal = c.doFinal(decodedValue)
|
||||
return String(decryptedVal)
|
||||
return try {
|
||||
val decodedValue = Base64.decode(encrypted.toByteArray(charset("UTF-8")), Base64.DEFAULT)
|
||||
val decryptedVal = c.doFinal(decodedValue)
|
||||
String(decryptedVal)
|
||||
} catch (error: IllegalArgumentException) {
|
||||
null
|
||||
} catch (e: GeneralSecurityException) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun getRandomIV(): String {
|
||||
|
|
|
|||
Loading…
Reference in a new issue