summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Pek <tehnick-8@yandex.ru>2017-03-24 20:42:26 (GMT)
committerBoris Pek <tehnick-8@yandex.ru>2017-03-24 20:42:26 (GMT)
commit922ff5bce5b241e6377ba917b0cf1871d684ce1d (patch)
tree991ee444d70c9e6ac8afa6f1cc5ff7b60f5f5b1c
parent3d45f5a57f0aab9c100f761f5ed0b6421b04e9e3 (diff)
downloadmxe-922ff5bce5b241e6377ba917b0cf1871d684ce1d.zip
mxe-922ff5bce5b241e6377ba917b0cf1871d684ce1d.tar.gz
mxe-922ff5bce5b241e6377ba917b0cf1871d684ce1d.tar.bz2
qca: add test
-rw-r--r--src/qca-test.cpp38
-rw-r--r--src/qca-test.pro13
-rw-r--r--src/qca.mk7
3 files changed, 58 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;
+}
diff --git a/src/qca-test.pro b/src/qca-test.pro
new file mode 100644
index 0000000..0d4fb25
--- /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 00ac124..438163d 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
+