From a557e25b6136b3123543aa0a3c1ef94980400e14 Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 6 Feb 2023 07:27:11 -0800 Subject: [PATCH] Attempt to fix short passwords on mac+win --- src/connection.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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;