aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordEntry.kt12
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt3
2 files changed, 9 insertions, 6 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordEntry.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordEntry.kt
index 2b1f1eee..392bc749 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordEntry.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordEntry.kt
@@ -11,7 +11,7 @@ import java.io.UnsupportedEncodingException
class PasswordEntry(private val content: String) {
val password: String
val username: String?
- val digits: String?
+ val digits: String
val totpSecret: String?
val totpPeriod: Long
val totpAlgorithm: String
@@ -87,11 +87,13 @@ class PasswordEntry(private val content: String) {
return null
}
- private fun findOtpDigits(decryptedContent: String): String? {
+ private fun findOtpDigits(decryptedContent: String): String {
decryptedContent.split("\n".toRegex()).forEach { line ->
- if (line.startsWith("optauth://totp/") ||
- line.startsWith("otpauth://hotp/"))
- return Uri.parse(line).getQueryParameters("digits").toString()
+ if (line.startsWith("otpauth://totp/") ||
+ line.startsWith("otpauth://hotp/") &&
+ Uri.parse(line).getQueryParameter("digits") != null) {
+ return Uri.parse(line).getQueryParameter("digits")!!
+ }
}
return "6"
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt
index dc9d399f..4e3b756c 100644
--- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt
@@ -316,7 +316,8 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
entry.totpSecret,
Date().time / (1000 * entry.totpPeriod),
entry.totpAlgorithm,
- entry.digits)
+ entry.digits
+ )
} else {
// we only want to calculate and show HOTP if the user requests it
crypto_copy_otp.setOnClickListener {