Fix force conversion of KDBX3 if using Quick Unlock

* Use SHA256 hash of the file path of the database to generate a UUID when using the KDBX3 format. This restores the original behavior of using the file path as the quick unlock lookup key.
This commit is contained in:
Jonathan White 2024-05-27 07:32:28 -04:00
parent f80e79f71a
commit dd1a233859

View File

@ -1041,6 +1041,13 @@ void Database::stopModifiedTimer()
QUuid Database::publicUuid() QUuid Database::publicUuid()
{ {
// This feature requires KDBX4
if (m_data.formatVersion < KeePass2::FILE_VERSION_4) {
// Return the file path hash as a UUID for KDBX3
QCryptographicHash hasher(QCryptographicHash::Sha256);
hasher.addData(filePath().toUtf8());
return QUuid::fromRfc4122(hasher.result().left(16));
}
if (!publicCustomData().contains("KPXC_PUBLIC_UUID")) { if (!publicCustomData().contains("KPXC_PUBLIC_UUID")) {
publicCustomData().insert("KPXC_PUBLIC_UUID", QUuid::createUuid().toRfc4122()); publicCustomData().insert("KPXC_PUBLIC_UUID", QUuid::createUuid().toRfc4122());