From b428803c048e88a4dc8a1faa8b496aec516c0da6 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Mon, 22 Apr 2013 18:41:23 -0400 Subject: [PATCH] now assigning partition based on MD5 hash of subject --- openbr/openbr_plugin.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); } } } -- libgit2 0.21.4