aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/PassphraseGenerator.h
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2023-10-23 10:27:25 +0000
committersaturneric <[email protected]>2023-10-23 10:27:25 +0000
commit8fdeb3af49999f29e017b7f7a70bd36f020ba721 (patch)
treedb90267c3c88d488570a8e359bd511b64c5686d8 /src/core/function/PassphraseGenerator.h
parentfeat: improve project structure and add GRT for modules (diff)
downloadGpgFrontend-8fdeb3af49999f29e017b7f7a70bd36f020ba721.tar.gz
GpgFrontend-8fdeb3af49999f29e017b7f7a70bd36f020ba721.zip
perf: reduce header includes and improve build speed
Diffstat (limited to '')
-rw-r--r--src/core/function/PassphraseGenerator.h22
1 files changed, 2 insertions, 20 deletions
diff --git a/src/core/function/PassphraseGenerator.h b/src/core/function/PassphraseGenerator.h
index 8c0a63eb..dcbc83f5 100644
--- a/src/core/function/PassphraseGenerator.h
+++ b/src/core/function/PassphraseGenerator.h
@@ -26,8 +26,7 @@
*
*/
-#ifndef GPGFRONTEND_PASSPHRASEGENERATOR_H
-#define GPGFRONTEND_PASSPHRASEGENERATOR_H
+#pragma once
#include "core/GpgFrontendCore.h"
#include "core/GpgFunctionObject.h"
@@ -57,27 +56,10 @@ class GPGFRONTEND_CORE_EXPORT PassphraseGenerator
* @param len length of the passphrase
* @return std::string 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;
- }
+ std::string Generate(int len);
std::random_device rd_; ///< Random device
std::mt19937 mt_ = std::mt19937(rd_()); ///< Mersenne twister
};
} // namespace GpgFrontend
-
-#endif // GPGFRONTEND_PASSPHRASEGENERATOR_H