From 730da7ef0faf55f7bb90eccc41e7b57997ba839d Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 5 Sep 2020 05:39:17 +0530 Subject: Otp: use runCatching to replace exception handling Signed-off-by: Harsh Shandilya --- app/src/main/java/com/zeapo/pwdstore/model/PasswordEntry.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/com/zeapo/pwdstore/model') diff --git a/app/src/main/java/com/zeapo/pwdstore/model/PasswordEntry.kt b/app/src/main/java/com/zeapo/pwdstore/model/PasswordEntry.kt index 2cd31256..ea6255c4 100644 --- a/app/src/main/java/com/zeapo/pwdstore/model/PasswordEntry.kt +++ b/app/src/main/java/com/zeapo/pwdstore/model/PasswordEntry.kt @@ -4,6 +4,7 @@ */ package com.zeapo.pwdstore.model +import com.github.michaelbull.result.get import com.zeapo.pwdstore.utils.Otp import com.zeapo.pwdstore.utils.TotpFinder import com.zeapo.pwdstore.utils.UriTotpFinder @@ -55,7 +56,7 @@ class PasswordEntry(content: String, private val totpFinder: TotpFinder = UriTot fun calculateTotpCode(): String? { if (totpSecret == null) return null - return Otp.calculateCode(totpSecret, Date().time / (1000 * totpPeriod), totpAlgorithm, digits) + return Otp.calculateCode(totpSecret, Date().time / (1000 * totpPeriod), totpAlgorithm, digits).get() } val extraContentWithoutAuthData by lazy { -- cgit v1.2.3