mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 23:17:13 +03:00
Merge branch 'clientSideEncryptionV3' of github.com:nextcloud/client into clientSideEncryptionV3
This commit is contained in:
commit
34e6534813
1 changed files with 16 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue