* @brief Implementation of the iGenerator interface
* @author Enar Vaikene
*
- * Copyright (c) 2011 Enar Vaikene
+ * Copyright (c) 2011-2012 Enar Vaikene
*
* This file is part of the eVaf C++ cross-platform application development framework.
*
*/
#include "module.h"
-#include "version.h"
#include <Common/iLogger>
#include <Common/iRegistry>
#include <QtCore>
VER_EXPORT_VERSION_INFO()
-Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, eVaf::PswGen::Generator::Module)
using namespace eVaf;
using namespace eVaf::PswGen;
using namespace eVaf::PswGen::Generator::Internal;
GeneratorImpl::GeneratorImpl()
- : iGenerator()
+ : QObject()
{
setObjectName(QString("%1.iGenerator").arg(VER_MODULE_NAME_STR));
hash.addData(inputString);
QByteArray result = hash.result().toBase64();
if (length > 0)
- return result.left(length);
- else
- return result;
+ result.resize(length);
+
+ if (flags & uint(ALPHANUMERIC)) {
+ // Convert all characters to alpha-numeric
+ for (int i = 0; i < result.size(); ++i) {
+ unsigned char c = result.at(i);
+ while (isalnum(c) == 0)
+ c++;
+ result[i] = c;
+ }
+ }
+
+ return result;
}