aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/PassphraseGenerator.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/function/PassphraseGenerator.h')
-rw-r--r--src/core/function/PassphraseGenerator.h32
1 files changed, 7 insertions, 25 deletions
diff --git a/src/core/function/PassphraseGenerator.h b/src/core/function/PassphraseGenerator.h
index a61356fe..2e5925b6 100644
--- a/src/core/function/PassphraseGenerator.h
+++ b/src/core/function/PassphraseGenerator.h
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2021 Saturneric
+ * Copyright (C) 2021 Saturneric <[email protected]>
*
* This file is part of GpgFrontend.
*
@@ -20,17 +20,15 @@
* 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
*
*/
-#ifndef GPGFRONTEND_PASSPHRASEGENERATOR_H
-#define GPGFRONTEND_PASSPHRASEGENERATOR_H
+#pragma once
-#include "core/GpgFrontendCore.h"
-#include "core/GpgFunctionObject.h"
+#include "core/function/basic/GpgFunctionObject.h"
namespace GpgFrontend {
@@ -55,29 +53,13 @@ class GPGFRONTEND_CORE_EXPORT PassphraseGenerator
* @brief generate passphrase
*
* @param len length of the passphrase
- * @return std::string passphrase
+ * @return QString passphrase
*/
- std::string Generate(int len) {
- std::uniform_int_distribution<int> dist(999, 99999);
-
- auto file_string = boost::format("KeyPackage_%1%") % dist(mt_);
- static const char alphanum[] =
- "0123456789"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz";
- std::string tmp_str;
- tmp_str.reserve(len);
-
- for (int i = 0; i < len; ++i) {
- tmp_str += alphanum[dist(mt_) % (sizeof(alphanum) - 1)];
- }
- return tmp_str;
- }
+ auto Generate(int len) -> QString;
+ private:
std::random_device rd_; ///< Random device
std::mt19937 mt_ = std::mt19937(rd_()); ///< Mersenne twister
};
} // namespace GpgFrontend
-
-#endif // GPGFRONTEND_PASSPHRASEGENERATOR_H