diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index 9227cf4..7870963 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -15,6 +15,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include +#include #include #include #include @@ -443,7 +444,9 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) newTemplates.insert(i+1, allPartitionTemplate); } } else { - newTemplates[i].file.set("Partition", rand() % crossValidate); + const QByteArray md5 = QCryptographicHash::hash(newTemplates[i].file.subject().toLatin1(), QCryptographicHash::Md5); + // Select the right 8 hex characters so that it can be represented as a 64 bit integer without overflow + newTemplates[i].file.set("Partition", md5.toHex().right(8).toULongLong(0, 16) % crossValidate); } } }