Merge branch 'clientSideEncryptionV3' of github.com:nextcloud/client into clientSideEncryptionV3

This commit is contained in:
Tomaz Canabrava 2017-11-20 18:01:48 +01:00
commit 34e6534813

View file

@ -1,10 +1,25 @@
#include "wordlist.h"
#include <openssl/rand.h>
namespace OCC {
namespace WordList {
#include <initializer_list>
int getRandomNumber(int max) {
unsigned char d[8];
RAND_bytes(d, 8);
unsigned int num = 0;
for (int i = 0; i < 8; i++) {
num = num << 8;
num += d[i];
}
return num % max;
}
QStringList getRandomWords(int nr)
{
QStringList wordList = {
@ -2060,7 +2075,7 @@ QStringList getRandomWords(int nr)
QStringList randomWords;
while(randomWords.size() != nr) {
QString currWord = wordList.at(rand() % wordList.size());
QString currWord = wordList.at(getRandomNumber(wordList.size()));
if (!randomWords.contains(currWord)) {
randomWords.append(currWord);
}