18
#include "TestCryptoHash.h"
20
#include "crypto/Crypto.h"
21
#include "crypto/CryptoHash.h"
25
QTEST_GUILESS_MAIN(TestCryptoHash)
27
void TestCryptoHash::initTestCase()
29
QVERIFY(Crypto::init());
32
void TestCryptoHash::test()
34
CryptoHash cryptoHash1(CryptoHash::Sha256);
35
QCOMPARE(cryptoHash1.result(),
36
QByteArray::fromHex("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"));
38
QByteArray source2 = QString("KeePassX").toLatin1();
39
QByteArray result2 = CryptoHash::hash(source2, CryptoHash::Sha256);
40
QCOMPARE(result2, QByteArray::fromHex("0b56e5f65263e747af4a833bd7dd7ad26a64d7a4de7c68e52364893dca0766b4"));
42
CryptoHash cryptoHash3(CryptoHash::Sha256);
43
cryptoHash3.addData(QString("KeePa").toLatin1());
44
cryptoHash3.addData(QString("ssX").toLatin1());
45
QCOMPARE(cryptoHash3.result(),
46
QByteArray::fromHex("0b56e5f65263e747af4a833bd7dd7ad26a64d7a4de7c68e52364893dca0766b4"));
48
CryptoHash cryptoHash2(CryptoHash::Sha512);
49
QCOMPARE(cryptoHash2.result(),
50
QByteArray::fromHex("cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff831"
51
"8d2877eec2f63b931bd47417a81a538327af927da3e"));
53
QByteArray result3 = CryptoHash::hash(source2, CryptoHash::Sha512);
55
QByteArray::fromHex("0d41b612584ed39ff72944c29494573e40f4bb95283455fae2e0be1e3565aa9f48057d59e6ff"
56
"d777970e282871c25a549a2763e5b724794f312c97021c42f91d"));
58
CryptoHash cryptoHash4(CryptoHash::Sha512);
59
cryptoHash4.addData(QString("KeePa").toLatin1());
60
cryptoHash4.addData(QString("ssX").toLatin1());
61
QCOMPARE(cryptoHash4.result(),
62
QByteArray::fromHex("0d41b612584ed39ff72944c29494573e40f4bb95283455fae2e0be1e3565aa9f48057d59e6ffd777970e2"
63
"82871c25a549a2763e5b724794f312c97021c42f91d"));