From b639c43b2484a0aebf0065fd6f525eeaec18d67c Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sun, 19 Sep 2010 20:13:23 +0200 Subject: [PATCH] Remove unneeded toHex() calls. --- tests/TestCryptoHash.cpp | 12 ++++++------ tests/TestSymmetricCipher.cpp | 28 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/TestCryptoHash.cpp b/tests/TestCryptoHash.cpp index e81d82313..11f2ccca5 100644 --- a/tests/TestCryptoHash.cpp +++ b/tests/TestCryptoHash.cpp @@ -40,18 +40,18 @@ void TestCryptoHash::test() QVERIFY(Crypto::selfTest()); CryptoHash cryptoHash1(CryptoHash::Sha256); - QCOMPARE(QString(cryptoHash1.result().toHex()), - QString("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")); + QCOMPARE(cryptoHash1.result(), + QByteArray::fromHex("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")); QByteArray source2 = QString("KeePassX").toAscii(); - QString result2 = CryptoHash::hash(source2, CryptoHash::Sha256).toHex(); - QCOMPARE(result2, QString("0b56e5f65263e747af4a833bd7dd7ad26a64d7a4de7c68e52364893dca0766b4")); + QByteArray result2 = CryptoHash::hash(source2, CryptoHash::Sha256); + QCOMPARE(result2, QByteArray::fromHex("0b56e5f65263e747af4a833bd7dd7ad26a64d7a4de7c68e52364893dca0766b4")); CryptoHash cryptoHash3(CryptoHash::Sha256); cryptoHash3.addData(QString("KeePa").toAscii()); cryptoHash3.addData(QString("ssX").toAscii()); - QCOMPARE(QString(cryptoHash3.result().toHex()), - QString("0b56e5f65263e747af4a833bd7dd7ad26a64d7a4de7c68e52364893dca0766b4")); + QCOMPARE(cryptoHash3.result(), + QByteArray::fromHex("0b56e5f65263e747af4a833bd7dd7ad26a64d7a4de7c68e52364893dca0766b4")); } QTEST_MAIN(TestCryptoHash); diff --git a/tests/TestSymmetricCipher.cpp b/tests/TestSymmetricCipher.cpp index 044199794..bb3ff4e7a 100644 --- a/tests/TestSymmetricCipher.cpp +++ b/tests/TestSymmetricCipher.cpp @@ -51,8 +51,8 @@ void TestSymmetricCipher::testAes256CbcEncryption() SymmetricCipher cipher(SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Encrypt, key, iv); QCOMPARE(cipher.blockSize(), 16); - QCOMPARE(QString(cipher.process(plainText).toHex()), - QString(cipherText.toHex())); + QCOMPARE(cipher.process(plainText), + cipherText); QBuffer buffer; SymmetricCipherStream stream(&buffer, SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Encrypt, key, iv); @@ -63,13 +63,13 @@ void TestSymmetricCipher::testAes256CbcEncryption() buffer.reset(); buffer.buffer().clear(); stream.write(plainText.left(16)); - QCOMPARE(QString(buffer.data().toHex()), QString(cipherText.left(16).toHex())); + QCOMPARE(buffer.data(), cipherText.left(16)); QVERIFY(stream.reset()); buffer.reset(); buffer.buffer().clear(); stream.write(plainText.left(10)); - QCOMPARE(QString(buffer.data().toHex()), QString()); + QCOMPARE(buffer.data(), QByteArray()); QVERIFY(stream.reset()); buffer.reset(); @@ -91,28 +91,28 @@ void TestSymmetricCipher::testAes256CbcDecryption() SymmetricCipher cipher(SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Decrypt, key, iv); QCOMPARE(cipher.blockSize(), 16); - QCOMPARE(QString(cipher.process(cipherText).toHex()), - QString(plainText.toHex())); + QCOMPARE(cipher.process(cipherText), + plainText); QBuffer buffer(&cipherText); SymmetricCipherStream stream(&buffer, SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Decrypt, key, iv); buffer.open(QIODevice::ReadOnly); stream.open(QIODevice::ReadOnly); - QCOMPARE(QString(stream.read(10).toHex()), - QString(plainText.left(10).toHex())); + QCOMPARE(stream.read(10), + plainText.left(10)); buffer.reset(); stream.reset(); - QCOMPARE(QString(stream.read(20).toHex()), - QString(plainText.left(20).toHex())); + QCOMPARE(stream.read(20), + plainText.left(20)); buffer.reset(); stream.reset(); - QCOMPARE(QString(stream.read(16).toHex()), - QString(plainText.left(16).toHex())); + QCOMPARE(stream.read(16), + plainText.left(16)); buffer.reset(); stream.reset(); - QCOMPARE(QString(stream.read(100).toHex()), - QString(plainText.toHex())); + QCOMPARE(stream.read(100), + plainText); } QTEST_MAIN(TestSymmetricCipher);