X-Git-Url: https://vaikene.ee/gitweb/highlight.css?a=blobdiff_plain;f=src%2Fapps%2FPswGen%2FGenerator%2Fmodule.cpp;h=bca195479139b33c2e953b0f9c7a0bc2366f3605;hb=a81a943bee20df3c7eb34bafb3e3fe878facfe4e;hp=27354f52a630575fa5e9e1ff3f99d3f58b501923;hpb=3352f7acc232104985807b9f470cb12bcb2b47c2;p=evaf diff --git a/src/apps/PswGen/Generator/module.cpp b/src/apps/PswGen/Generator/module.cpp index 27354f5..bca1954 100644 --- a/src/apps/PswGen/Generator/module.cpp +++ b/src/apps/PswGen/Generator/module.cpp @@ -3,7 +3,7 @@ * @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. * @@ -18,7 +18,6 @@ */ #include "module.h" -#include "version.h" #include #include @@ -26,7 +25,6 @@ #include VER_EXPORT_VERSION_INFO() -Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, eVaf::PswGen::Generator::Module) using namespace eVaf; using namespace eVaf::PswGen; @@ -71,7 +69,7 @@ void Module::done() using namespace eVaf::PswGen::Generator::Internal; GeneratorImpl::GeneratorImpl() - : iGenerator() + : QObject() { setObjectName(QString("%1.iGenerator").arg(VER_MODULE_NAME_STR)); @@ -94,7 +92,17 @@ QString GeneratorImpl::generatePassword(QString const & name, QString const & ma 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; }