PictureCrypt  1.4.1
An image-steganography project
Go to the documentation of this file.
1 #ifndef MODELPC_H
2 #define MODELPC_H
4 #include <QObject>
5 #include <QImage>
6 #include <QByteArray>
7 #include <QColor>
8 #include <QPoint>
9 #include <QVector>
10 #include <QProcess>
11 #include <QTime>
12 #include <QFileInfo>
13 #include <QtGui>
14 #include <QtCore/QRandomGenerator>
15 #include <QPair>
17 #include "qaesencryption.h"
18 #include <QCryptographicHash>
33 class ModelPC : public QObject
34 {
36 public:
37  ModelPC();
39  static QImage *Encrypt(QByteArray data, QImage *image, int _mode, QString key = "", int _bitsUsed = 8, QString *_error = nullptr);
40  static QByteArray Decrypt(QImage * image, QString key, int _mode = 0, QString *_error = nullptr);
42 signals:
49  void alertView(QString messageCode, bool isWarning);
54  void saveData(QByteArray data);
59  void saveImage(QImage *image);
65  void setProgress(int val);
67 public slots:
68  QImage *encrypt(QByteArray data, QImage *image, int _mode, QString key = "", int _bitsUsed = 8, QString *_error = nullptr);
69  QByteArray decrypt(QImage * image, QString key, int _mode = 0, QString *_error = nullptr);
70  void fail(QString message);
71  void alert(QString message, bool isWarning = false);
73 public:
74  QByteArray unzip(QByteArray data, QByteArray key);
80  bool success;
84  long version;
88  QString versionString;
92  QString defaultJPHSDir;
93 protected:
94  static QImage *Inject(QByteArray encr_data, QImage * image, int _mode, int _bitsUsed = 8, QString *_error = nullptr);
96  void circuit(QImage * image, QByteArray * data, long long int countBytes);
97  void jphs(QImage * image, QByteArray * data);
98  void processPixel(QPoint pos, QVector<QPoint> *were, bool isEncrypt);
99  void encryptv1_4(QImage *image, QByteArray data, QString key);
100  QByteArray decryptv1_3(QImage * image, QString key);
101  QByteArray decryptv1_4(QImage * image, QString key);
102  void proccessPixelsv1_4(QImage *image, QByteArray* data, QByteArray key, bool isEncrypt, QVector<QPair<QPoint, QPair<int, int> > > *were, long long size = -1);
103  QByteArray zip(QByteArray data, QByteArray key);
108  QString * error;
109 private:
110  int bitsUsed;
111  bool fileExists(QString path);
112  QByteArray bytes(long long n);
113  unsigned int mod(int input);
114  QByteArray ver_byte;
115  QColor RGBbytes(long long byte);
116  QString generateVersionString(long ver);
117  uint randSeed();
118  bool isTry = false;
120  QByteArray * circuitData;
121  QImage * circuitImage;
122  long long circuitCountBytes;
123  long cur;
124  bool mustGoOn(bool isEncrypt);
126  QVector <bool> bitsBuffer;
127  long pop(int bits = -1);
128  void push(int data, int bits = -1);
130  void setError(QString word);
131  QByteArray GetRandomBytes(long long count = 32);
132 protected slots:
133  QImage *inject(QByteArray encr_data, QImage * image, int _mode, int _bitsUsed = 8, QString *_error = nullptr);
134 };
136 #endif // MODELPC_H
QByteArray decryptv1_4(QImage *image, QString key)
ModelPC::decryptv1_4 Decrypts data from image in v1.4+.
Definition: modelpc.cpp:603
QByteArray zip(QByteArray data, QByteArray key)
ModelPC::zip Zip function, copy of EncryptDialog::zip Used for ModelPC in custom projects, other than PictureCrypt.
Definition: modelpc.cpp:897
QString versionString
versionString Version as string
Definition: modelpc.h:88
long version
version Version of the class
Definition: modelpc.h:84
ModelPC::ModelPC Constructor Unit tests are run here.
Definition: modelpc.cpp:9
void alertView(QString messageCode, bool isWarning)
alertView Signal to be called to create MessageBox.
void proccessPixelsv1_4(QImage *image, QByteArray *data, QByteArray key, bool isEncrypt, QVector< QPair< QPoint, QPair< int, int > > > *were, long long size=-1)
ModelPC::proccessPixelsv1_4 Hides (or retrieves) data to/from pixels.
Definition: modelpc.cpp:664
The ModelPC class Model Layer of the app. Main class that does the work of PictureCrypt logic Control...
Definition: modelpc.h:33
QString defaultJPHSDir
defaultJPHSDir Default JPHS directory
Definition: modelpc.h:92
QImage * encrypt(QByteArray data, QImage *image, int _mode, QString key="", int _bitsUsed=8, QString *_error=nullptr)
ModelPC::encrypt Slot to zip and inject data and provide it with some extra stuff After completion st...
Definition: modelpc.cpp:51
void saveData(QByteArray data)
saveData Signal to be called to save data from ModelPC::decrypt.
static QImage * Inject(QByteArray encr_data, QImage *image, int _mode, int _bitsUsed=8, QString *_error=nullptr)
Definition: modelpc.cpp:29
void jphs(QImage *image, QByteArray *data)
ModelPC::jphs JPHS function to use jphide and jpseek (currently under development) ...
Definition: modelpc.cpp:298
void circuit(QImage *image, QByteArray *data, long long int countBytes)
ModelPC::circuit The brain of the app. Via special circuit stores data in image.
Definition: modelpc.cpp:359
QString * error
error Current error
Definition: modelpc.h:108
void encryptv1_4(QImage *image, QByteArray data, QString key)
ModelPC::encryptv1_4 Encrypts and injects data to image used in v1.4+.
Definition: modelpc.cpp:561
QImage * inject(QByteArray encr_data, QImage *image, int _mode, int _bitsUsed=8, QString *_error=nullptr)
ModelPC::inject Slot to be called when encrypt mode in ViewPC is selected and started.
Definition: modelpc.cpp:139
void alert(QString message, bool isWarning=false)
ModelPC::alert Function emits signal ModelPC::alertView and calls ViewPC::alert.
Definition: modelpc.cpp:941
void setProgress(int val)
setProgress Signal to be called to set progress of ProgressDialog.
QByteArray decryptv1_3(QImage *image, QString key)
ModelPC::decryptv1_3 Decrytps data from image in v1.3.
Definition: modelpc.cpp:778
void fail(QString message)
ModelPC::fail Slot to stop execution of cryption.
Definition: modelpc.cpp:283
QByteArray decrypt(QImage *image, QString key, int _mode=0, QString *_error=nullptr)
ModelPC::decrypt Slot to be called when decrypt mode in ViewPC is selected and started.
Definition: modelpc.cpp:212
bool success
success Flag that true by default, but in case of error or cancelling of ProgressDialog it turns to f...
Definition: modelpc.h:80
QByteArray unzip(QByteArray data, QByteArray key)
ModelPC::unzip Unzip data from ModelPC::decrypt. Just mirrored EncryptDialog::zip.
Definition: modelpc.cpp:880
Definition: modelpc.h:38
static QByteArray Decrypt(QImage *image, QString key, int _mode=0, QString *_error=nullptr)
Definition: modelpc.cpp:34
void saveImage(QImage *image)
saveImage Signal to be called to save image from ModelPC::encrypt.
static QImage * Encrypt(QByteArray data, QImage *image, int _mode, QString key="", int _bitsUsed=8, QString *_error=nullptr)
Definition: modelpc.cpp:24
void processPixel(QPoint pos, QVector< QPoint > *were, bool isEncrypt)
ModelPC::processPixel Processes every pixel. Reads its contains or writes data.
Definition: modelpc.cpp:500