aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/PassphraseGenerator.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-01-12 06:02:37 +0000
committersaturneric <[email protected]>2024-01-12 06:02:37 +0000
commitbf538056b24a68b8fd235b1c50991ee8eb46a776 (patch)
treee1bab54095b80df62b321fb5bd69453f9f951b05 /src/core/function/PassphraseGenerator.cpp
parentfeat: improve api and ui of keys import and export (diff)
downloadGpgFrontend-bf538056b24a68b8fd235b1c50991ee8eb46a776.tar.gz
GpgFrontend-bf538056b24a68b8fd235b1c50991ee8eb46a776.zip
refactor: use QString instead of std::string and improve threading system
Diffstat (limited to 'src/core/function/PassphraseGenerator.cpp')
-rw-r--r--src/core/function/PassphraseGenerator.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/core/function/PassphraseGenerator.cpp b/src/core/function/PassphraseGenerator.cpp
index 6d0db65d..b7f1e877 100644
--- a/src/core/function/PassphraseGenerator.cpp
+++ b/src/core/function/PassphraseGenerator.cpp
@@ -28,23 +28,21 @@
#include "PassphraseGenerator.h"
-#include <boost/format.hpp>
-
namespace GpgFrontend {
-auto PassphraseGenerator::Generate(int len) -> std::string {
- std::uniform_int_distribution<int> dist(999, 99999);
-
- auto file_string = boost::format("KeyPackage_%1%") % dist(mt_);
+auto PassphraseGenerator::Generate(int len) -> QString {
+ auto file_string = QString("KeyPackage_%1")
+ .arg(QRandomGenerator::global()->bounded(999, 99999));
static const char kAlphanum[] =
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
- std::string tmp_str;
+ QString tmp_str;
tmp_str.reserve(len);
for (int i = 0; i < len; ++i) {
- tmp_str += kAlphanum[dist(mt_) % (sizeof(kAlphanum) - 1)];
+ tmp_str += kAlphanum[QRandomGenerator::global()->bounded(
+ static_cast<quint32>(sizeof(kAlphanum)))];
}
return tmp_str;
}