From 67ef758d539560b0426086cf6bf1cc68624c1e2f Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 8 Jun 2023 17:16:47 +0800 Subject: [PATCH] Simplify loop to write bytes to password Signed-off-by: Claudio Cambra --- src/gui/filedetails/sharemodel.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/filedetails/sharemodel.cpp b/src/gui/filedetails/sharemodel.cpp index 146339b50efb..e755718de8bd 100644 --- a/src/gui/filedetails/sharemodel.cpp +++ b/src/gui/filedetails/sharemodel.cpp @@ -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); }