summaryrefslogtreecommitdiff
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.kt17
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt6
2 files changed, 13 insertions, 10 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordEntry.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordEntry.kt
index 82204317..2b1f1eee 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordEntry.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordEntry.kt
@@ -89,19 +89,17 @@ class PasswordEntry(private val content: String) {
private fun findOtpDigits(decryptedContent: String): String? {
decryptedContent.split("\n".toRegex()).forEach { line ->
- if (line.startsWith("otpauth://totp/")) {
- return Uri.parse(line).getQueryParameter("digits")
- }
- if (line.startsWith("otpauth://hotp/")) {
- return Uri.parse(line).getQueryParameter("digits")
- }
+ if (line.startsWith("optauth://totp/") ||
+ line.startsWith("otpauth://hotp/"))
+ return Uri.parse(line).getQueryParameters("digits").toString()
}
return "6"
}
private fun findTotpPeriod(decryptedContent: String): Long {
decryptedContent.split("\n".toRegex()).forEach { line ->
- if (line.startsWith("otpauth://totp/") && Uri.parse(line).getQueryParameter("period") != null) {
+ if (line.startsWith("otpauth://totp/") &&
+ Uri.parse(line).getQueryParameter("period") != null) {
return java.lang.Long.parseLong(Uri.parse(line).getQueryParameter("period")!!)
}
}
@@ -110,8 +108,9 @@ class PasswordEntry(private val content: String) {
private fun findTotpAlgorithm(decryptedContent: String): String {
decryptedContent.split("\n".toRegex()).forEach { line ->
- if (line.startsWith("otpauth://totp/") && Uri.parse(line).getQueryParameter("algorithm") != null) {
- return Uri.parse(line).getQueryParameter("algorithm")
+ if (line.startsWith("otpauth://totp/") &&
+ Uri.parse(line).getQueryParameter("algorithm") != null) {
+ return Uri.parse(line).getQueryParameter("algorithm")!!
}
}
return "sha1"
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 055f50bf..dc9d399f 100644
--- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt
@@ -312,7 +312,11 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
)
}
crypto_otp_show.text =
- Otp.calculateCode(entry.totpSecret, Date().time / (1000 * entry.totpPeriod), entry.totpAlgorithm, entry.digits)
+ Otp.calculateCode(
+ entry.totpSecret,
+ Date().time / (1000 * entry.totpPeriod),
+ entry.totpAlgorithm,
+ entry.digits)
} else {
// we only want to calculate and show HOTP if the user requests it
crypto_copy_otp.setOnClickListener {