aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/KeyPackageOperator.h
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2022-02-06 09:34:14 +0000
committerSaturneric <[email protected]>2022-02-06 09:34:39 +0000
commitcacca627a62ab2eba9eb4d37cfea40629ca0a89a (patch)
treec596c3c2252ebb0e3792ab4c561d7c7cd3f3e4b0 /src/core/function/KeyPackageOperator.h
parent<refactor>(core, ui): Adjust the core code directory structure. (diff)
downloadGpgFrontend-cacca627a62ab2eba9eb4d37cfea40629ca0a89a.tar.gz
GpgFrontend-cacca627a62ab2eba9eb4d37cfea40629ca0a89a.zip
<refactor>(src): Move and split the Global Settings Station
1. Move Global Settings Station to core 2. Separate the logic of DataObject 3. Resolve dependencies
Diffstat (limited to 'src/core/function/KeyPackageOperator.h')
-rw-r--r--src/core/function/KeyPackageOperator.h35
1 files changed, 6 insertions, 29 deletions
diff --git a/src/core/function/KeyPackageOperator.h b/src/core/function/KeyPackageOperator.h
index ee81e86e..cd344688 100644
--- a/src/core/function/KeyPackageOperator.h
+++ b/src/core/function/KeyPackageOperator.h
@@ -39,7 +39,7 @@ namespace GpgFrontend {
*
*/
class KeyPackageOperator {
-public:
+ public:
/**
* @brief generate passphrase for key package and save it to file
*
@@ -87,44 +87,21 @@ public:
const std::filesystem::path &phrase_path,
GpgFrontend::GpgImportInformation &import_info);
-private:
- /**
- * @brief genearte passphrase
- *
- * @param len length of the passphrase
- * @return std::string passphrase
- */
- static std::string generate_passphrase(const int len) {
- std::random_device rd_; ///< Random device
- auto mt_ = std::mt19937(rd_()); ///< Mersenne twister
-
- std::uniform_int_distribution<int> dist(999, 99999);
- 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;
- }
-
+ private:
/**
* @brief generate key package name
*
* @return std::string key package name
*/
static std::string generate_key_package_name() {
- std::random_device rd_; ///< Random device
- auto mt_ = std::mt19937(rd_()); ///< Mersenne twister
+ std::random_device rd_; ///< Random device
+ auto mt_ = std::mt19937(rd_()); ///< Mersenne twister
std::uniform_int_distribution<int> dist(999, 99999);
auto file_string = boost::format("KeyPackage_%1%") % dist(mt_);
return file_string.str();
}
};
-} // namespace GpgFrontend
+} // namespace GpgFrontend
-#endif // GPGFRONTEND_KEYPACKAGEOPERATOR_H
+#endif // GPGFRONTEND_KEYPACKAGEOPERATOR_H