Remove unneeded toHex() calls.

This commit is contained in:
Felix Geyer 2010-09-19 20:13:23 +02:00
parent 24158bb032
commit b639c43b24
2 changed files with 20 additions and 20 deletions

View File

@ -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);

View File

@ -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);