mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Simplify password generation in sharemodel
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
c4d1bdf46f
commit
32acf504cb
@ -37,10 +37,15 @@ QString createRandomPassword()
|
||||
constexpr auto numChars = 24;
|
||||
QString passwd;
|
||||
|
||||
while(passwd.length() < numChars) {
|
||||
const auto remainingChars = numChars - passwd.length();
|
||||
unsigned char unsignedCharArray[remainingChars];
|
||||
RAND_bytes(unsignedCharArray, remainingChars);
|
||||
unsigned char unsignedCharArray[numChars];
|
||||
RAND_bytes(unsignedCharArray, numChars);
|
||||
|
||||
for (auto i = 0; i < numChars; i++) {
|
||||
auto byte = unsignedCharArray[i];
|
||||
byte %= asciiRange;
|
||||
byte += asciiMin;
|
||||
passwd.append(byte);
|
||||
}
|
||||
|
||||
for (auto i = 0; i < remainingChars; i++) {
|
||||
auto byte = unsignedCharArray[i];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user