libquentier  0.4.0
The library for rich desktop clients of Evernote service
EncryptionManager.h
1 /*
2  * Copyright 2016 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/utility/Macros.h>
23 #include <quentier/utility/Linkage.h>
24 #include <quentier/types/ErrorString.h>
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 = Q_NULLPTR);
43  virtual ~EncryptionManager();
44 
45  bool decrypt(const QString & encryptedText, const QString & passphrase,
46  const QString & cipher, const size_t keyLength,
47  QString & decryptedText, ErrorString & errorDescription);
48 
49  bool encrypt(const QString & textToEncrypt, const QString & passphrase,
50  QString & cipher, size_t & keyLength,
51  QString & encryptedText, ErrorString & errorDescription);
52 
53 Q_SIGNALS:
54  void decryptedText(QString text, bool success, ErrorString errorDescription, QUuid requestId);
55  void encryptedText(QString encryptedText, bool success, ErrorString errorDescription, QUuid requestId);
56 
57 public Q_SLOTS:
58  void onDecryptTextRequest(QString encryptedText, QString passphrase,
59  QString cipher, size_t keyLength, QUuid requestId);
60  void onEncryptTextRequest(QString textToEncrypt, QString passphrase,
61  QString cipher, size_t keyLength, QUuid requestId);
62 
63 private:
64  EncryptionManagerPrivate * const d_ptr;
65  Q_DECLARE_PRIVATE(EncryptionManager)
66 };
67 
68 } // namespace quentier
69 
70 #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:38
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:38