Skip to content

Commit

Permalink
PR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-megh-l committed Jan 22, 2025
1 parent 3d2a958 commit c79976f
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c79976f

Please sign in to comment.