Commit b428803c048e88a4dc8a1faa8b496aec516c0da6

Authored by Josh Klontz
1 parent 90c6b04a

now assigning partition based on MD5 hash of subject

Showing 1 changed file with 4 additions and 1 deletions
openbr/openbr_plugin.cpp
... ... @@ -15,6 +15,7 @@
15 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16  
17 17 #include <QCoreApplication>
  18 +#include <QCryptographicHash>
18 19 #include <QFutureSynchronizer>
19 20 #include <QMetaProperty>
20 21 #include <QPointF>
... ... @@ -443,7 +444,9 @@ TemplateList TemplateList::fromGallery(const br::File &amp;gallery)
443 444 newTemplates.insert(i+1, allPartitionTemplate);
444 445 }
445 446 } else {
446   - newTemplates[i].file.set("Partition", rand() % crossValidate);
  447 + const QByteArray md5 = QCryptographicHash::hash(newTemplates[i].file.subject().toLatin1(), QCryptographicHash::Md5);
  448 + // Select the right 8 hex characters so that it can be represented as a 64 bit integer without overflow
  449 + newTemplates[i].file.set("Partition", md5.toHex().right(8).toULongLong(0, 16) % crossValidate);
447 450 }
448 451 }
449 452 }
... ...