aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/model
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-09-05 05:39:17 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-09-05 22:49:03 +0530
commit730da7ef0faf55f7bb90eccc41e7b57997ba839d (patch)
treebb5f3ad9c6bdd37ce8b4505061d7290b6adf1ea1 /app/src/main/java/com/zeapo/pwdstore/model
parent104c6550f651434cb60393ac167c7d3b46014442 (diff)
downloadHardenedPass-730da7ef0faf55f7bb90eccc41e7b57997ba839d.tar.gz
HardenedPass-730da7ef0faf55f7bb90eccc41e7b57997ba839d.zip
Otp: use runCatching to replace exception handling
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/model')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/model/PasswordEntry.kt3
1 files changed, 2 insertions, 1 deletions
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 {