Simplify loop to write bytes to password

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-06-08 17:16:47 +08:00
parent 4c8007e461
commit 9df47cf1cc
No known key found for this signature in database
GPG key ID: C839200C384636B0

View file

@ -63,10 +63,9 @@ QString createRandomPassword()
RAND_bytes(unsignedCharArray.data(), numChars);
for (auto i = 0; i < numChars; i++) {
auto byte = unsignedCharArray[i];
byte %= asciiRange + 1;
byte += asciiMin;
for (const auto newChar : unsignedCharArray) {
// Ensure byte is within asciiRange
const auto byte = (newChar % (asciiRange + 1)) + asciiMin;
passwd.append(byte);
}