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.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/core/function/PassphraseGenerator.cpp b/src/core/function/PassphraseGenerator.cpp
index de963fa1..b7f1e877 100644
--- a/src/core/function/PassphraseGenerator.cpp
+++ b/src/core/function/PassphraseGenerator.cpp
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2021 Saturneric
+ * Copyright (C) 2021 Saturneric <[email protected]>
*
* This file is part of GpgFrontend.
*
@@ -20,10 +20,30 @@
* the gpg4usb project, which is under GPL-3.0-or-later.
*
* All the source code of GpgFrontend was modified and released by
- * Saturneric<[email protected]> starting on May 12, 2021.
+ * Saturneric <[email protected]> starting on May 12, 2021.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "PassphraseGenerator.h"
+
+namespace GpgFrontend {
+
+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";
+ QString tmp_str;
+ tmp_str.reserve(len);
+
+ for (int i = 0; i < len; ++i) {
+ tmp_str += kAlphanum[QRandomGenerator::global()->bounded(
+ static_cast<quint32>(sizeof(kAlphanum)))];
+ }
+ return tmp_str;
+}
+} // namespace GpgFrontend \ No newline at end of file