2 #include "ui_encryptdialog.h" 17 ui->totalBytes->setText(QString::number(
data.size()));
20 long long int compr_data_size =
compr_data.size();
21 ui->zippedBytes->setText(QString::number(compr_data_size));
31 void EncryptDialog::alert(QString text)
34 t.setWindowTitle(tr(
"Message"));
35 t.setIcon(QMessageBox::Warning);
36 t.setWindowIcon(QIcon(
":/mail.png"));
49 QByteArray c_data = qCompress(
data, 9);
51 QByteArray hashKey = QCryptographicHash::hash(
key.toUtf8(), QCryptographicHash::Sha256);
60 inputFileName = QFileDialog::getOpenFileName(
this, tr(
"Open File"),
"/", tr(
"Images (*.png *.xpm *.jpg *.jpeg)"));
66 size = img.width() * img.height();
68 long long int compr_data_size =
compr_data.size();
69 ui->zippedBytes->setText(QString::number(compr_data_size));
71 ui->percentage->setText(
"");
74 double perc = (compr_data_size + 14) * 100 / (
size * 3) *
bitsUsed / 8;
75 ui->percentage->setText(QString::number(perc) +
"%");
85 alert(tr(
"Your encoding percentage is over 70% which is a bit ambiguous."));
90 key = ui->keyLine->text();
110 ui->bitsUsedLbl->setText(QString::number(value));
111 if(ui->percentage->text().isEmpty())
114 ui->percentage->setText(QString::number(perc) +
"%");
bool success
success Flag, if image was successfully selected and data was encrypted.
void on_fileButton_clicked()
EncryptDialog::on_fileButton_clicked Slot to select the image.
static QByteArray Crypt(QAESEncryption::Aes level, QAESEncryption::Mode mode, const QByteArray &rawText, const QByteArray &key, const QByteArray &iv=NULL, QAESEncryption::Padding padding=QAESEncryption::ISO)
Crypt Static encode function.
void on_buttonBox_rejected()
EncryptDialog::on_buttonBox_rejected Slot to reject the encryption.
QByteArray data
data Input data
QImage image
image Inputted image
bool goodPercentage
goodPercentage Flag if area of the used data via encryption is less than 70% of the area of the image...
void on_bitsSlider_valueChanged(int value)
EncryptDialog::on_bitsSlider_valueChanged Slot if value of the bits slider is changed.
long long int size
size Size of the image in square pixels
void on_buttonBox_accepted()
EncryptDialog::on_buttonBox_accepted Slot to start the encryption. Successful closing of the app...
The EncryptDialog class Class to get the image and key to store secret info.
int bitsUsed
bitsUsed Bits used per byte of pixel.
QString key
key Key to be used for encryption in EncrytDialog::zip
QByteArray zip()
EncryptDialog::zip Zipping algorithm It copresses the data and then compresses it using qCompress() ...
EncryptDialog(QByteArray _data, QWidget *parent=0)
EncryptDialog::EncryptDialog Constructor of the class. Input data is saved here and some variables ar...
QByteArray compr_data
compr_data Compressed data, aka Output data.
QString inputFileName
inputFileName Filename of the image.