diff --git a/src/connection.cpp b/src/connection.cpp index 5ba21aa..557a16c 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -152,11 +152,17 @@ QString randomPassword() { "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"; - const int passwordLength = 10; + // Assume we have low entropy randomness, + // so we generate a longer password than we probably need + const int passwordLength = 32; char* s = new char[passwordLength + 1]; for (int i = 0; i < passwordLength; ++i) { +#ifdef Q_OS_LINUX s[i] = alphanum[randombytes_uniform(sizeof(alphanum))]; +#else + s[i] = alphanum[rand() % (sizeof(alphanum) - 1)]; +#endif } s[passwordLength] = 0;