diff options
author | Boris Pek <tehnick-8@yandex.ru> | 2017-03-24 20:42:26 (GMT) |
---|---|---|
committer | Boris Pek <tehnick-8@yandex.ru> | 2017-03-24 20:42:26 (GMT) |
commit | 922ff5bce5b241e6377ba917b0cf1871d684ce1d (patch) | |
tree | 991ee444d70c9e6ac8afa6f1cc5ff7b60f5f5b1c /src/qca-test.cpp | |
parent | 3d45f5a57f0aab9c100f761f5ed0b6421b04e9e3 (diff) | |
download | mxe-922ff5bce5b241e6377ba917b0cf1871d684ce1d.zip mxe-922ff5bce5b241e6377ba917b0cf1871d684ce1d.tar.gz mxe-922ff5bce5b241e6377ba917b0cf1871d684ce1d.tar.bz2 |
qca: add test
Diffstat (limited to 'src/qca-test.cpp')
-rw-r--r-- | src/qca-test.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/qca-test.cpp b/src/qca-test.cpp new file mode 100644 index 0000000..73a6b5c --- /dev/null +++ b/src/qca-test.cpp @@ -0,0 +1,38 @@ +/* + * This file is part of MXE. See LICENSE.md for licensing information. + */ + +#include <QCoreApplication> +#include <QtCrypto> +#include <QDebug> + +#include <iostream> + +#ifdef QT_STATICPLUGIN +#include "import_plugins.h" +#endif + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + QCA::init(); + + QByteArray inputString = "Hello world!"; + if (a.arguments().size() > 1) { + inputString = a.arguments().at(1).toUtf8(); + } + std::cout << "input string:\n" << inputString.toStdString() << "\n\n"; + + // Calculate hashes of a string with all available hashing algorithms: + QByteArray outputString; + for (const QString &hastType : QCA::Hash::supportedTypes()) { + QCA::Hash hashObject(hastType); + hashObject.update(inputString); + outputString = hashObject.final().toByteArray().toHex(); + + std::cout << hastType.toStdString() << " hash:\n" + << outputString.toStdString() << "\n\n"; + } + + return 0; +} |