mirror of
https://github.com/QuasarApp/Qt-AES.git
synced 2025-04-27 14:14:31 +00:00
adding static classes
This commit is contained in:
parent
f171c9e0b7
commit
b601f21d68
@ -1,6 +1,32 @@
|
||||
#include "qaesencryption.h"
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
/*
|
||||
* Static Functions
|
||||
* */
|
||||
QByteArray QAESEncryption::Crypt(QAESEncryption::AES level, QAESEncryption::MODE mode, const QByteArray rawText, const QByteArray key, const QByteArray iv)
|
||||
{
|
||||
return QAESEncryption(level, mode).encode(rawText, key, iv);
|
||||
}
|
||||
|
||||
QByteArray QAESEncryption::Decrypt(QAESEncryption::AES level, QAESEncryption::MODE mode, const QByteArray rawText, const QByteArray key, const QByteArray iv)
|
||||
{
|
||||
return QAESEncryption(level, mode).decode(rawText, key, iv);
|
||||
}
|
||||
|
||||
QByteArray QAESEncryption::ExpandKey(QAESEncryption::AES level, QAESEncryption::MODE mode, const QByteArray key)
|
||||
{
|
||||
return QAESEncryption(level, mode).expandKey(key);
|
||||
}
|
||||
/*
|
||||
* End Static function declarations
|
||||
* */
|
||||
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* */
|
||||
QAESEncryption::QAESEncryption(QAESEncryption::AES level, QAESEncryption::MODE mode) : m_nb(4), m_blocklen(16), m_level(level), m_mode(mode)
|
||||
{
|
||||
m_state = NULL;
|
||||
@ -355,8 +381,6 @@ QByteArray QAESEncryption::decode(const QByteArray rawText, const QByteArray key
|
||||
QByteArray alignedText(rawText);
|
||||
QByteArray ivTemp(iv);
|
||||
|
||||
//alignedText.append(getPadding(rawText.size(), m_blocklen), 0); //filling the array with zeros
|
||||
|
||||
for(int i=0; i < alignedText.size(); i+= m_blocklen)
|
||||
{
|
||||
ret.append(invCipher(expandedKey, alignedText.mid(i, m_blocklen)));
|
||||
|
@ -19,10 +19,15 @@ public:
|
||||
CBC
|
||||
} MODE;
|
||||
|
||||
static QByteArray Crypt(QAESEncryption::AES level, QAESEncryption::MODE mode, const QByteArray rawText, const QByteArray key, const QByteArray iv = NULL);
|
||||
static QByteArray Decrypt(QAESEncryption::AES level, QAESEncryption::MODE mode, const QByteArray rawText, const QByteArray key, const QByteArray iv = NULL);
|
||||
static QByteArray ExpandKey(QAESEncryption::AES level, QAESEncryption::MODE mode, const QByteArray key);
|
||||
|
||||
QAESEncryption(QAESEncryption::AES level, QAESEncryption::MODE mode);
|
||||
|
||||
QByteArray encode(const QByteArray rawText, const QByteArray key, const QByteArray iv = NULL);
|
||||
QByteArray decode(const QByteArray rawText, const QByteArray key, const QByteArray iv = NULL);
|
||||
QByteArray expandKey(const QByteArray key);
|
||||
|
||||
signals:
|
||||
|
||||
@ -59,7 +64,7 @@ private:
|
||||
|
||||
quint8 getSBoxValue(quint8 num){return sbox[num];}
|
||||
quint8 getSBoxInvert(quint8 num){return rsbox[num];}
|
||||
QByteArray expandKey(const QByteArray key);
|
||||
|
||||
void addRoundKey(const quint8 round, const QByteArray expKey);
|
||||
void subBytes();
|
||||
void shiftRows();
|
||||
|
Loading…
x
Reference in New Issue
Block a user