LicenseSpring C++ SDK
Easily add Software Licensing to your application
CryptoProvider.h
Go to the documentation of this file.
1 #ifndef LS_CRYPTO_PROVIDER_H
2 #define LS_CRYPTO_PROVIDER_H
3 
4 #ifdef _MSC_VER
5 #pragma once
6 #pragma warning(push)
7 #pragma warning(disable : 4251)
8 #endif
9 
10 #include "APIDef.h"
11 #include <memory>
12 #include <string>
13 
14 namespace LicenseSpring
15 {
21 {
22 public:
23  using ptr_t = std::shared_ptr<CryptoProvider>;
24 
26  virtual ~CryptoProvider();
27 
31  virtual std::string encrypt(const std::string &inputString) = 0;
32 
36  virtual std::string decrypt(const std::string &inputString) = 0;
37 
40  virtual void setSalt(const std::string &salt);
41 
44  virtual void setKey(const std::string &key);
45 
48  bool isKeySet() const;
49 
50 protected:
51  std::string m_salt;
52  std::string m_key;
53 };
54 
57 {
58 public:
59  using ptr_t = std::shared_ptr<DefaultCryptoProvider>;
60 
64 
66  ~DefaultCryptoProvider() override;
67 
72  static ptr_t create() { return std::make_shared<DefaultCryptoProvider>(); }
73 
77  std::string encrypt(const std::string &inputString) override;
78 
82  std::string decrypt(const std::string &inputString) override;
83 
84 private:
85  const unsigned char *getKey(const std::string &key);
86 };
87 } // namespace LicenseSpring
88 
89 #ifdef _MSC_VER
90 #pragma warning(pop)
91 #endif
92 
93 #endif // LS_CRYPTO_PROVIDER_H
LicenseSpring::CryptoProvider::ptr_t
std::shared_ptr< CryptoProvider > ptr_t
Definition: CryptoProvider.h:23
LicenseSpring
Definition: BaseManager.h:16
LicenseSpring::CryptoProvider::m_key
std::string m_key
Definition: CryptoProvider.h:52
APIDef.h
LicenseSpring::DefaultCryptoProvider
If no CryptoProvider is set, this is the default CryptoProvider that will be used.
Definition: CryptoProvider.h:56
LicenseSpring::CryptoProvider
CryptoProvider interface.
Definition: CryptoProvider.h:20
LicenseSpring::DefaultCryptoProvider::create
static ptr_t create()
Allocates and constructs a DefaultCryptoProvider object and passes args to DefaultCryptoProvider().
Definition: CryptoProvider.h:72
LicenseSpring::CryptoProvider::m_salt
std::string m_salt
Definition: CryptoProvider.h:51
LS_API
#define LS_API
Definition: APIDef.h:23