aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/PassphraseGenerator.cpp
diff options
context:
space:
mode:
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;
}