X-Git-Url: https://vaikene.ee/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2Fapps%2FPswGen%2FGenerator%2Fmodule.cpp;h=9e24e561f39d16d317ab6b2371694366a393dd3c;hb=20e9a6027b85c947e59722a061de1479bc2d7953;hp=e19933ba4ed8c1fe30599ec6a572aa313a50cdb2;hpb=19bb35ea710505eb1951108bb4c9461315ad77a7;p=evaf diff --git a/src/apps/PswGen/Generator/module.cpp b/src/apps/PswGen/Generator/module.cpp index e19933b..9e24e56 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. * @@ -94,7 +94,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; }