Try to fix decodeHex method conflict in some devices

This commit is contained in:
J-Jamet
2021-01-20 11:42:09 +01:00
parent 7c38361844
commit 3fd13f3e3b
3 changed files with 4 additions and 4 deletions

View File

@@ -451,7 +451,7 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
return if (hashString != null
&& checkKeyFileHash(dataString, hashString)) {
Log.i(TAG, "Successful key file hash check.")
Hex.decodeHex(dataString)
Hex.decodeHex(dataString.toCharArray())
} else {
Log.e(TAG, "Unable to check the hash of the key file.")
null
@@ -477,7 +477,7 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
digest = MessageDigest.getInstance("SHA-256")
digest?.reset()
// hexadecimal encoding of the first 4 bytes of the SHA-256 hash of the key.
val dataDigest = digest.digest(Hex.decodeHex(data))
val dataDigest = digest.digest(Hex.decodeHex(data.toCharArray()))
.copyOfRange(0, 4)
.toHexString()
success = dataDigest == hash

View File

@@ -140,7 +140,7 @@ abstract class DatabaseVersioned<
when (keyData.size) {
32 -> return keyData
64 -> try {
return Hex.decodeHex(String(keyData))
return Hex.decodeHex(String(keyData).toCharArray())
} catch (ignoredException: Exception) {
// Key is not base 64, treat it as binary data
}

View File

@@ -138,7 +138,7 @@ data class OtpElement(var otpModel: OtpModel = OtpModel()) {
@Throws(IllegalArgumentException::class)
fun setHexSecret(secret: String) {
if (secret.isNotEmpty())
otpModel.secret = Hex.decodeHex(secret)
otpModel.secret = Hex.decodeHex(secret.toCharArray())
else
throw IllegalArgumentException()
}