From 922ff5bce5b241e6377ba917b0cf1871d684ce1d Mon Sep 17 00:00:00 2001 From: Boris Pek Date: Fri, 24 Mar 2017 23:42:26 +0300 Subject: [PATCH] qca: add test --- src/qca-test.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/qca-test.pro | 13 +++++++++++++ src/qca.mk | 7 +++++++ 3 files changed, 58 insertions(+) create mode 100644 src/qca-test.cpp create mode 100644 src/qca-test.pro diff --git a/src/qca-test.cpp b/src/qca-test.cpp new file mode 100644 index 00000000..73a6b5c1 --- /dev/null +++ b/src/qca-test.cpp @@ -0,0 +1,38 @@ +/* + * This file is part of MXE. See LICENSE.md for licensing information. + */ + +#include +#include +#include + +#include + +#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; +} diff --git a/src/qca-test.pro b/src/qca-test.pro new file mode 100644 index 00000000..0d4fb256 --- /dev/null +++ b/src/qca-test.pro @@ -0,0 +1,13 @@ +# This file is part of MXE. See LICENSE.md for licensing information. + +TEMPLATE = app +greaterThan(QT_MAJOR_VERSION, 4): TARGET = test-qca5 +else: TARGET = test-qca +SOURCES += qca-test.cpp +CONFIG += crypto console +QMAKE_CXXFLAGS += -Wall -Werror + +# For static linking: +# QTPLUGIN += qca-gnupg qca-logger qca-ossl qca-softstore qca-qt5 +# LIBS += -L$$[QT_INSTALL_PLUGINS]/crypto + diff --git a/src/qca.mk b/src/qca.mk index 00ac1247..438163df 100644 --- a/src/qca.mk +++ b/src/qca.mk @@ -26,4 +26,11 @@ define $(PKG)_BUILD -DQCA_MAN_INSTALL_DIR="$(BUILD_DIR)/null" $(MAKE) -C '$(BUILD_DIR)' -j $(JOBS) $(MAKE) -C '$(BUILD_DIR)' -j 1 install + + $(if $(BUILD_SHARED), \ + mkdir '$(BUILD_DIR)/test-qca' + cd '$(BUILD_DIR)/test-qca' && '$(PREFIX)/$(TARGET)/qt5/bin/qmake' '$(PWD)/src/qca-test.pro' + $(MAKE) -C '$(BUILD_DIR)/test-qca' -j $(JOBS) $(BUILD_TYPE) + $(INSTALL) -m755 '$(BUILD_DIR)/test-qca/$(BUILD_TYPE)/test-qca5.exe' '$(PREFIX)/$(TARGET)/bin/') endef +