libquentier  0.5.0
The library for rich desktop clients of Evernote service
EncryptionManager.h
1 /*
2  * Copyright 2016-2020 Dmitry Ivanov
3  *
4  * This file is part of libquentier
5  *
6  * libquentier is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * libquentier is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef LIB_QUENTIER_UTILITY_ENCRYPTION_MANAGER_H
20 #define LIB_QUENTIER_UTILITY_ENCRYPTION_MANAGER_H
21 
22 #include <quentier/types/ErrorString.h>
23 #include <quentier/utility/Linkage.h>
24 #include <quentier/utility/Macros.h>
25 
26 #include <QObject>
27 #include <QString>
28 #include <QUuid>
29 
30 namespace quentier {
31 
32 QT_FORWARD_DECLARE_CLASS(EncryptionManagerPrivate)
33 
34 
39 class QUENTIER_EXPORT EncryptionManager: public QObject
40 {
41  Q_OBJECT
42 public:
43  explicit EncryptionManager(QObject * parent = nullptr);
44  virtual ~EncryptionManager();
45 
46  bool decrypt(
47  const QString & encryptedText, const QString & passphrase,
48  const QString & cipher, const size_t keyLength,
49  QString & decryptedText, ErrorString & errorDescription);
50 
51  bool encrypt(
52  const QString & textToEncrypt, const QString & passphrase,
53  QString & cipher, size_t & keyLength,
54  QString & encryptedText, ErrorString & errorDescription);
55 
56 Q_SIGNALS:
57  void decryptedText(
58  QString text, bool success, ErrorString errorDescription,
59  QUuid requestId);
60 
61  void encryptedText(
62  QString encryptedText, bool success, ErrorString errorDescription,
63  QUuid requestId);
64 
65 public Q_SLOTS:
66  void onDecryptTextRequest(
67  QString encryptedText, QString passphrase, QString cipher,
68  size_t keyLength, QUuid requestId);
69 
70  void onEncryptTextRequest(
71  QString textToEncrypt, QString passphrase, QString cipher,
72  size_t keyLength, QUuid requestId);
73 
74 private:
75  EncryptionManagerPrivate * const d_ptr;
76  Q_DECLARE_PRIVATE(EncryptionManager)
77 };
78 
79 } // namespace quentier
80 
81 #endif // LIB_QUENTIER_UTILITY_ENCRYPTION_MANAGER_H
The EncryptionManager class provides both synchronous methods to encrypt or decrypt given text with p...
Definition: EncryptionManager.h:40
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:44