mirror of
https://github.com/QuasarApp/Qt-AES.git
synced 2025-05-09 03:29:34 +00:00
fix types and new added new test
This commit is contained in:
parent
39bc5e170e
commit
3d4c882683
@ -508,5 +508,5 @@ QByteArray QAESEncryption::decode(const QByteArray &rawText, const QByteArray &k
|
||||
|
||||
QByteArray QAESEncryption::removePadding(const QByteArray &rawText)
|
||||
{
|
||||
return RemovePadding(rawText, m_padding);
|
||||
return RemovePadding(rawText, (Padding) m_padding);
|
||||
}
|
||||
|
@ -194,5 +194,23 @@ void AesTest::OFB256String()
|
||||
QByteArray encodeText = encryption.encode(inputStr.toLocal8Bit(), hashKey, iv);
|
||||
|
||||
QByteArray decodedText = encryption.removePadding(encryption.decode(encodeText, hashKey, iv));
|
||||
QCOMPARE(inputStr, decodedText);
|
||||
QCOMPARE(inputStr, QString(decodedText));
|
||||
}
|
||||
|
||||
void AesTest::CBC256StringEven()
|
||||
{
|
||||
QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::CBC);
|
||||
|
||||
//16 byte string
|
||||
QString inputStr("1234567890123456");
|
||||
QString key("123456789123");
|
||||
|
||||
QByteArray hashKey = QCryptographicHash::hash(key.toLocal8Bit(), QCryptographicHash::Sha256);
|
||||
QByteArray encodeText = encryption.encode(inputStr.toLocal8Bit(), hashKey, iv);
|
||||
QByteArray decodeText = encryption.decode(encodeText, hashKey, iv);
|
||||
|
||||
QString decodedString = QString(encryption.removePadding(decodeText));
|
||||
|
||||
QCOMPARE(QString(decodeText), decodedString);
|
||||
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ private slots:
|
||||
void OFB128Crypt();
|
||||
void OFB256String();
|
||||
|
||||
void CBC256StringEven();
|
||||
|
||||
void cleanupTestCase(){}
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user