--- /dev/null
+/**
+ * @file PswGen/Generator/generator.cpp
+ * @brief Implementation of the iGenerator interface
+ * @author Enar Vaikene
+ *
+ * Copyright (c) 2011 Enar Vaikene
+ *
+ * This file is part of the eVaf C++ cross-platform application development framework.
+ *
+ * This file can be used under the terms of the GNU General Public License
+ * version 3.0 as published by the Free Software Foundation and appearing in
+ * the file LICENSE included in the packaging of this file. Please review the
+ * the following information to ensure the GNU General Public License version
+ * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * Alternatively, this file may be used in accordance with the Commercial License
+ * Agreement provided with the Software.
+ */
+
+#include "generator.h"
+#include "version.h"
+
+#include <Common/iLogger>
+#include <Common/iRegistry>
+
+#include <QtCore>
+
+using namespace eVaf;
+using namespace evaf::PswGen;
+using namespace eVaf::PswGen::Generator;
+
+//-------------------------------------------------------------------
+
+Generator::Generator()
+ : Plugins::iPlugin()
+ , mReady(false)
+{
+ setObjectName(QString("%1.%2").arg(VER_MODULE_NAME_STR).arg(__FUNCTION__));
+
+ mGenerator = new Internal::GeneratorImpl;
+
+ EVAF_INFO("%s created", qPrintable(objectName()));
+}
+
+Generator::~Generator()
+{
+ delete mGenerator;
+
+ EVAF_INFO("%s destroyed", qPrintable(objectName()));
+}
+
+bool Generator::init(const QString & args)
+{
+ Q_UNUSED(args);
+
+ if (!mGenerator->init())
+ return false;
+
+ mReady = true;
+
+ EVAF_INFO("%s initialized", qPrintable(objectName()));
+
+ return true;
+}
+
+void Generator::done()
+{
+ mReady = false;
+
+ mGenerator->done();
+
+ EVAF_INFO("%s finalized", qPrintable(objectName()));
+}
+
+
+//-------------------------------------------------------------------
+
+using namespace eVaf::PswGen::Generator::Internal;
+
+GeneratorImpl::GeneratorImpl()
+ : iGenerator()
+{
+ setObjectName(QString("%1.iGenerator").arg(VER_MODULE_NAME_STR));
+
+ Common::iRegistry::instance()->registerInterface("iGenerator", this);
+
+ EVAF_INFO("%s created", qPrintable(objectName()));
+}
+
+GeneratorImpl::~GeneratorImpl()
+{
+ EVAF_INFO("%s destroyed", qPrintable(objectName()));
+}
+
+bool GeneratorImpl::init()
+{
+ EVAF_INFO("%s initialized", qPrintable(objectName()));
+
+ return true;
+}
+
+void GeneratorImpl::done()
+{
+ EVAF_INFO("%s finalized", qPrintable(objectName()));
+}
+
+QString GeneratorImpl::generatePassword(char const * const name, char const * const masterPassword, int length, uint flags)
+{
+ QByteArray inputString = QString("%1%2").arg(name).arg(masterPassword).toLatin1();
+ QCryptographicHash hash(QCryptographicHash::Md5);
+ hash.addData(inputString);
+ QByteArray result = hash.result().toBase64();
+ if (length > 0)
+ return result.left(length);
+ else
+ return result;
+}
+
+
+//-------------------------------------------------------------------
+
+VER_EXPORT_VERSION_INFO()
+Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, Generator)