]> git.lyx.org Git - features.git/blob - src/support/CryptographicEncryption.h
support for formal math script
[features.git] / src / support / CryptographicEncryption.h
1 // -*- C++ -*-
2 /**
3  * \file CryptographicEncryption.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Peter Kümmel
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef CRYPTOCRAPHIC_ENCYPTION_H
13 #define CRYPTOCRAPHIC_ENCYPTION_H
14
15 #include <QCryptographicHash>
16
17 namespace lyx {
18 namespace support {
19
20
21 class CryptographicEncryption
22 {
23 public:
24         CryptographicEncryption();
25
26         enum Keytype {
27                 Password = 0,
28                 KeytypeCount
29         };
30
31         bool encyrpt(QByteArray const & plain, QByteArray * encrypted, QByteArray const & key);
32         bool decyrpt(QByteArray const & encrypted, QByteArray * plain, QByteArray const & key);
33
34         QByteArray bytesToKey(QByteArray const &);
35         QByteArray stringToKey(QString const &);
36
37 private:
38         int blockAlign(int blockSize, QByteArray& bytes);
39         int blockDealign(QByteArray& bytes);
40         QByteArray hash(QByteArray const & bytes, QCryptographicHash::Algorithm);
41         bool aesEnryption(QByteArray const & in, QByteArray* out, QByteArray const & key, bool encrypt);
42 };
43
44
45 }
46 }
47
48 #endif