GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
KeyPackageOperator.h
1 
29 #ifndef GPGFRONTEND_KEYPACKAGEOPERATOR_H
30 #define GPGFRONTEND_KEYPACKAGEOPERATOR_H
31 
32 #include "core/GpgFrontendCore.h"
33 #include "core/function/gpg/GpgKeyImportExporter.h"
34 
35 namespace GpgFrontend {
36 
41 class GPGFRONTEND_CORE_EXPORT KeyPackageOperator {
42  public:
51  static bool GeneratePassphrase(const std::filesystem::path &phrase_path,
52  std::string &phrase);
53 
59  static std::string GenerateKeyPackageName();
60 
72  static bool GenerateKeyPackage(const std::filesystem::path &key_package_path,
73  const std::string &key_package_name,
74  KeyIdArgsListPtr &key_ids, std::string &phrase,
75  bool secret);
76 
86  static bool ImportKeyPackage(const std::filesystem::path &key_package_path,
87  const std::filesystem::path &phrase_path,
89 
90  private:
96  static std::string generate_key_package_name() {
97  std::random_device rd_;
98  auto mt_ = std::mt19937(rd_());
99 
100  std::uniform_int_distribution<int> dist(999, 99999);
101  auto file_string = boost::format("KeyPackage_%1%") % dist(mt_);
102  return file_string.str();
103  }
104 };
105 } // namespace GpgFrontend
106 
107 #endif // GPGFRONTEND_KEYPACKAGEOPERATOR_H
Definition: GpgKeyImportExporter.h:57
give the possibility to import or export a key package
Definition: KeyPackageOperator.h:41
static std::string generate_key_package_name()
generate key package name
Definition: KeyPackageOperator.h:96
Definition: CoreCommonUtil.cpp:29