mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-25 19:41:34 -08:00
Fix TOTP secret uppercase #381
This commit is contained in:
1 parent
fdc2095b42
commit
66611db261
2 files changed
+5
-3
No files matched your search
@@ -29,6 +29,7 @@ import com.kunzisoft.keepass.otp.OtpElement.Companion.MIN_TOTP_PERIOD
|
||||
import com.kunzisoft.keepass.otp.OtpTokenType
|
||||
import com.kunzisoft.keepass.otp.OtpType
|
||||
import com.kunzisoft.keepass.otp.TokenCalculator
|
||||
import java.util.*
|
||||
|
||||
class SetOTPDialogFragment : DialogFragment() {
|
||||
|
||||
@@ -246,7 +247,7 @@ class SetOTPDialogFragment : DialogFragment() {
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
s?.toString()?.let { userString ->
|
||||
try {
|
||||
mOtpElement.setBase32Secret(userString)
|
||||
mOtpElement.setBase32Secret(userString.toUpperCase(Locale.ENGLISH))
|
||||
otpSecretContainer?.error = null
|
||||
} catch (exception: Exception) {
|
||||
otpSecretContainer?.error = getString(R.string.error_otp_secret_key)
|
||||
|
||||
@@ -125,8 +125,9 @@ data class OtpElement(var otpModel: OtpModel = OtpModel()) {
|
||||
|
||||
@Throws(IllegalArgumentException::class)
|
||||
fun setBase32Secret(secret: String) {
|
||||
if (secret.isNotEmpty() && checkBase32Secret(secret))
|
||||
otpModel.secret = Base32().decode(secret.toByteArray())
|
||||
val secretUppercase = secret.toUpperCase(Locale.ENGLISH)
|
||||
if (secret.isNotEmpty() && checkBase32Secret(secretUppercase))
|
||||
otpModel.secret = Base32().decode(secretUppercase.toByteArray())
|
||||
else
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user