From: Enar Vaikene Date: Mon, 4 Jun 2012 07:07:47 +0000 (+0300) Subject: Implemented the ALPHANUMERIC flag for password generation. Makes sure that all the... X-Git-Url: https://vaikene.ee/gitweb/pswgen09.html?a=commitdiff_plain;h=20e9a6027b85c947e59722a061de1479bc2d7953;p=evaf Implemented the ALPHANUMERIC flag for password generation. Makes sure that all the characters in the generated password are alpha-numeric only. --- 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; } diff --git a/src/apps/PswGen/Generator/version.h b/src/apps/PswGen/Generator/version.h index b118cdc..c2e78d0 100644 --- a/src/apps/PswGen/Generator/version.h +++ b/src/apps/PswGen/Generator/version.h @@ -3,7 +3,7 @@ * @brief Version information for eVaf modules * @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. * @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,1,1,1 +#define VER_FILE_VERSION 0,1,2,2 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.1.1.1\0" +#define VER_FILE_VERSION_STR "0.1.2.2\0" /** * Module/library name (shall end with \0)