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 
25 #include <QObject>
26 #include <QString>
27 #include <QUuid>
28 
29 namespace quentier {
30 
31 QT_FORWARD_DECLARE_CLASS(EncryptionManagerPrivate)
32 
33 
38 class QUENTIER_EXPORT EncryptionManager : public QObject
39 {
40  Q_OBJECT
41 public:
42  explicit EncryptionManager(QObject * parent = nullptr);
43  virtual ~EncryptionManager();
44 
45  bool decrypt(
46  const QString & encryptedText, const QString & passphrase,
47  const QString & cipher, const size_t keyLength, QString & decryptedText,
48  ErrorString & errorDescription);
49 
50  bool encrypt(
51  const QString & textToEncrypt, const QString & passphrase,
52  QString & cipher, size_t & keyLength, QString & encryptedText,
53  ErrorString & errorDescription);
54 
55 Q_SIGNALS:
56  void decryptedText(
57  QString text, bool success, ErrorString errorDescription,
58  QUuid requestId);
59 
60  void encryptedText(
61  QString encryptedText, bool success, ErrorString errorDescription,
62  QUuid requestId);
63 
64 public Q_SLOTS:
65  void onDecryptTextRequest(
66  QString encryptedText, QString passphrase, QString cipher,
67  size_t keyLength, QUuid requestId);
68 
69  void onEncryptTextRequest(
70  QString textToEncrypt, QString passphrase, QString cipher,
71  size_t keyLength, QUuid requestId);
72 
73 private:
74  EncryptionManagerPrivate * const d_ptr;
75  Q_DECLARE_PRIVATE(EncryptionManager)
76 };
77 
78 } // namespace quentier
79 
80 #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:39
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:44