mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-02 17:44:46 -05:00
Remove unneeded toHex() calls.
This commit is contained in:
parent
24158bb032
commit
b639c43b24
@ -40,18 +40,18 @@ void TestCryptoHash::test()
|
|||||||
QVERIFY(Crypto::selfTest());
|
QVERIFY(Crypto::selfTest());
|
||||||
|
|
||||||
CryptoHash cryptoHash1(CryptoHash::Sha256);
|
CryptoHash cryptoHash1(CryptoHash::Sha256);
|
||||||
QCOMPARE(QString(cryptoHash1.result().toHex()),
|
QCOMPARE(cryptoHash1.result(),
|
||||||
QString("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"));
|
QByteArray::fromHex("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"));
|
||||||
|
|
||||||
QByteArray source2 = QString("KeePassX").toAscii();
|
QByteArray source2 = QString("KeePassX").toAscii();
|
||||||
QString result2 = CryptoHash::hash(source2, CryptoHash::Sha256).toHex();
|
QByteArray result2 = CryptoHash::hash(source2, CryptoHash::Sha256);
|
||||||
QCOMPARE(result2, QString("0b56e5f65263e747af4a833bd7dd7ad26a64d7a4de7c68e52364893dca0766b4"));
|
QCOMPARE(result2, QByteArray::fromHex("0b56e5f65263e747af4a833bd7dd7ad26a64d7a4de7c68e52364893dca0766b4"));
|
||||||
|
|
||||||
CryptoHash cryptoHash3(CryptoHash::Sha256);
|
CryptoHash cryptoHash3(CryptoHash::Sha256);
|
||||||
cryptoHash3.addData(QString("KeePa").toAscii());
|
cryptoHash3.addData(QString("KeePa").toAscii());
|
||||||
cryptoHash3.addData(QString("ssX").toAscii());
|
cryptoHash3.addData(QString("ssX").toAscii());
|
||||||
QCOMPARE(QString(cryptoHash3.result().toHex()),
|
QCOMPARE(cryptoHash3.result(),
|
||||||
QString("0b56e5f65263e747af4a833bd7dd7ad26a64d7a4de7c68e52364893dca0766b4"));
|
QByteArray::fromHex("0b56e5f65263e747af4a833bd7dd7ad26a64d7a4de7c68e52364893dca0766b4"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(TestCryptoHash);
|
QTEST_MAIN(TestCryptoHash);
|
||||||
|
@ -51,8 +51,8 @@ void TestSymmetricCipher::testAes256CbcEncryption()
|
|||||||
SymmetricCipher cipher(SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Encrypt, key, iv);
|
SymmetricCipher cipher(SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Encrypt, key, iv);
|
||||||
QCOMPARE(cipher.blockSize(), 16);
|
QCOMPARE(cipher.blockSize(), 16);
|
||||||
|
|
||||||
QCOMPARE(QString(cipher.process(plainText).toHex()),
|
QCOMPARE(cipher.process(plainText),
|
||||||
QString(cipherText.toHex()));
|
cipherText);
|
||||||
|
|
||||||
QBuffer buffer;
|
QBuffer buffer;
|
||||||
SymmetricCipherStream stream(&buffer, SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Encrypt, key, iv);
|
SymmetricCipherStream stream(&buffer, SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Encrypt, key, iv);
|
||||||
@ -63,13 +63,13 @@ void TestSymmetricCipher::testAes256CbcEncryption()
|
|||||||
buffer.reset();
|
buffer.reset();
|
||||||
buffer.buffer().clear();
|
buffer.buffer().clear();
|
||||||
stream.write(plainText.left(16));
|
stream.write(plainText.left(16));
|
||||||
QCOMPARE(QString(buffer.data().toHex()), QString(cipherText.left(16).toHex()));
|
QCOMPARE(buffer.data(), cipherText.left(16));
|
||||||
|
|
||||||
QVERIFY(stream.reset());
|
QVERIFY(stream.reset());
|
||||||
buffer.reset();
|
buffer.reset();
|
||||||
buffer.buffer().clear();
|
buffer.buffer().clear();
|
||||||
stream.write(plainText.left(10));
|
stream.write(plainText.left(10));
|
||||||
QCOMPARE(QString(buffer.data().toHex()), QString());
|
QCOMPARE(buffer.data(), QByteArray());
|
||||||
|
|
||||||
QVERIFY(stream.reset());
|
QVERIFY(stream.reset());
|
||||||
buffer.reset();
|
buffer.reset();
|
||||||
@ -91,28 +91,28 @@ void TestSymmetricCipher::testAes256CbcDecryption()
|
|||||||
SymmetricCipher cipher(SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Decrypt, key, iv);
|
SymmetricCipher cipher(SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Decrypt, key, iv);
|
||||||
QCOMPARE(cipher.blockSize(), 16);
|
QCOMPARE(cipher.blockSize(), 16);
|
||||||
|
|
||||||
QCOMPARE(QString(cipher.process(cipherText).toHex()),
|
QCOMPARE(cipher.process(cipherText),
|
||||||
QString(plainText.toHex()));
|
plainText);
|
||||||
|
|
||||||
QBuffer buffer(&cipherText);
|
QBuffer buffer(&cipherText);
|
||||||
SymmetricCipherStream stream(&buffer, SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Decrypt, key, iv);
|
SymmetricCipherStream stream(&buffer, SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Decrypt, key, iv);
|
||||||
buffer.open(QIODevice::ReadOnly);
|
buffer.open(QIODevice::ReadOnly);
|
||||||
stream.open(QIODevice::ReadOnly);
|
stream.open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
QCOMPARE(QString(stream.read(10).toHex()),
|
QCOMPARE(stream.read(10),
|
||||||
QString(plainText.left(10).toHex()));
|
plainText.left(10));
|
||||||
buffer.reset();
|
buffer.reset();
|
||||||
stream.reset();
|
stream.reset();
|
||||||
QCOMPARE(QString(stream.read(20).toHex()),
|
QCOMPARE(stream.read(20),
|
||||||
QString(plainText.left(20).toHex()));
|
plainText.left(20));
|
||||||
buffer.reset();
|
buffer.reset();
|
||||||
stream.reset();
|
stream.reset();
|
||||||
QCOMPARE(QString(stream.read(16).toHex()),
|
QCOMPARE(stream.read(16),
|
||||||
QString(plainText.left(16).toHex()));
|
plainText.left(16));
|
||||||
buffer.reset();
|
buffer.reset();
|
||||||
stream.reset();
|
stream.reset();
|
||||||
QCOMPARE(QString(stream.read(100).toHex()),
|
QCOMPARE(stream.read(100),
|
||||||
QString(plainText.toHex()));
|
plainText);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(TestSymmetricCipher);
|
QTEST_MAIN(TestSymmetricCipher);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user