mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Try to fix decodeHex method conflict in some devices
This commit is contained in:
@@ -451,7 +451,7 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
|
|||||||
return if (hashString != null
|
return if (hashString != null
|
||||||
&& checkKeyFileHash(dataString, hashString)) {
|
&& checkKeyFileHash(dataString, hashString)) {
|
||||||
Log.i(TAG, "Successful key file hash check.")
|
Log.i(TAG, "Successful key file hash check.")
|
||||||
Hex.decodeHex(dataString)
|
Hex.decodeHex(dataString.toCharArray())
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Unable to check the hash of the key file.")
|
Log.e(TAG, "Unable to check the hash of the key file.")
|
||||||
null
|
null
|
||||||
@@ -477,7 +477,7 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
|
|||||||
digest = MessageDigest.getInstance("SHA-256")
|
digest = MessageDigest.getInstance("SHA-256")
|
||||||
digest?.reset()
|
digest?.reset()
|
||||||
// hexadecimal encoding of the first 4 bytes of the SHA-256 hash of the key.
|
// 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)
|
.copyOfRange(0, 4)
|
||||||
.toHexString()
|
.toHexString()
|
||||||
success = dataDigest == hash
|
success = dataDigest == hash
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ abstract class DatabaseVersioned<
|
|||||||
when (keyData.size) {
|
when (keyData.size) {
|
||||||
32 -> return keyData
|
32 -> return keyData
|
||||||
64 -> try {
|
64 -> try {
|
||||||
return Hex.decodeHex(String(keyData))
|
return Hex.decodeHex(String(keyData).toCharArray())
|
||||||
} catch (ignoredException: Exception) {
|
} catch (ignoredException: Exception) {
|
||||||
// Key is not base 64, treat it as binary data
|
// Key is not base 64, treat it as binary data
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ data class OtpElement(var otpModel: OtpModel = OtpModel()) {
|
|||||||
@Throws(IllegalArgumentException::class)
|
@Throws(IllegalArgumentException::class)
|
||||||
fun setHexSecret(secret: String) {
|
fun setHexSecret(secret: String) {
|
||||||
if (secret.isNotEmpty())
|
if (secret.isNotEmpty())
|
||||||
otpModel.secret = Hex.decodeHex(secret)
|
otpModel.secret = Hex.decodeHex(secret.toCharArray())
|
||||||
else
|
else
|
||||||
throw IllegalArgumentException()
|
throw IllegalArgumentException()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user