diff --git a/Habitica/build.gradle b/Habitica/build.gradle index 953185b87..7d6d06480 100644 --- a/Habitica/build.gradle +++ b/Habitica/build.gradle @@ -150,7 +150,7 @@ android { buildConfigField "String", "TESTING_LEVEL", "\"production\"" multiDexEnabled true - versionCode 2161 + versionCode 2165 versionName "1.10" } diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/Keyhelper.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/Keyhelper.kt index fce65360d..b0a970157 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/Keyhelper.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/Keyhelper.kt @@ -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 {