| LicenseSpring C++ SDK 7.27.0 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 {
19 class LS_API CryptoProvider
20 {
21 public:
22 using ptr_t = std::shared_ptr<CryptoProvider>;
23
25 virtual ~CryptoProvider();
26
30 virtual std::string encrypt( const std::string& inputString ) = 0;
31
35 virtual std::string decrypt( const std::string& inputString ) = 0;
36
39 virtual void setSalt( const std::string& salt );
40
43 virtual void setKey( const std::string& key );
44
47 bool isKeySet() const;
48
49 protected:
50 std::string m_salt;
51 std::string m_key;
52 };
53
55 class LS_API DefaultCryptoProvider final : public CryptoProvider
56 {
57 public:
58 using ptr_t = std::shared_ptr<DefaultCryptoProvider>;
59
62 DefaultCryptoProvider();
63
65 ~DefaultCryptoProvider() override;
66
69 static ptr_t create()
70 {
71 return std::make_shared<DefaultCryptoProvider>();
72 }
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 LicenseSpirng
88
89 #ifdef _MSC_VER
90 #pragma warning( pop )
91 #endif
92
93 #endif // LS_CRYPTO_PROVIDER_H
LicenseSpring::CryptoProvider
CryptoProvider interface.
Definition: CryptoProvider.h:19
LicenseSpring
Definition: BaseManager.h:15
APIDef.h
LicenseSpring::CryptoProvider::ptr_t
std::shared_ptr< CryptoProvider > ptr_t
Definition: CryptoProvider.h:22
LicenseSpring::DefaultCryptoProvider::create
static ptr_t create()
Allocates and constructs a DefaultCryptoProvider object and passes args to DefaultCryptoProvider().
Definition: CryptoProvider.h:69
LicenseSpring::CryptoProvider::m_salt
std::string m_salt
Definition: CryptoProvider.h:50
LicenseSpring::CryptoProvider::m_key
std::string m_key
Definition: CryptoProvider.h:51
LS_API
#define LS_API
Macros that expands to dllexport, dllimport or nothing on non Windows platforms or in case of static ...
Definition: APIDef.h:22
LicenseSpring::DefaultCryptoProvider
If no CryptoProvider is set, this is the default CryptoProvider that will be used.
Definition: CryptoProvider.h:55