From c79976f0a6fb60919e0b1e388c4442e3ce6fb5a6 Mon Sep 17 00:00:00 2001 From: cp-megh Date: Wed, 22 Jan 2025 11:15:51 +0530 Subject: [PATCH] PR changes --- .../yourspace/data/service/location/JourneyKtx.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/data/src/main/java/com/canopas/yourspace/data/service/location/JourneyKtx.kt b/data/src/main/java/com/canopas/yourspace/data/service/location/JourneyKtx.kt index 312de120..8870f4ae 100644 --- a/data/src/main/java/com/canopas/yourspace/data/service/location/JourneyKtx.kt +++ b/data/src/main/java/com/canopas/yourspace/data/service/location/JourneyKtx.kt @@ -9,7 +9,12 @@ import timber.log.Timber import java.util.Base64 import java.util.UUID -fun String.toBytes(): ByteArray = Base64.getDecoder().decode(this) +fun String.toBytes(): ByteArray? = try { + Base64.getDecoder().decode(this) +} catch (e: Exception) { + Timber.e(e, "Failed to decode base64 string") + null +} fun ByteArray.encodeToString(): String = Base64.getEncoder().encodeToString(this) @@ -94,9 +99,9 @@ fun LocationJourney.toEncryptedLocationJourney( ) } -fun GroupCipher.decryptPoint(data: ByteArray): Double? { +fun GroupCipher.decryptPoint(data: ByteArray?): Double? { return try { - decrypt(data).toString(Charsets.UTF_8).toDoubleOrNull() + data?.let { decrypt(it).toString(Charsets.UTF_8).toDoubleOrNull() } } catch (e: Exception) { Timber.e(e, "Failed to decrypt double") null