]>
vaikene.ee Git - evaf/blob - src/apps/PswGen/Generator/generator.cpp
2 * @file PswGen/Generator/generator.cpp
3 * @brief Implementation of the iGenerator interface
6 * Copyright (c) 2011 Enar Vaikene
8 * This file is part of the eVaf C++ cross-platform application development framework.
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
20 #include "generator.h"
23 #include <Common/iLogger>
24 #include <Common/iRegistry>
29 using namespace eVaf::PswGen
;
30 using namespace eVaf::PswGen::Generator
;
32 //-------------------------------------------------------------------
38 setObjectName(QString("%1.%2").arg(VER_MODULE_NAME_STR
).arg(__FUNCTION__
));
40 mGenerator
= new Internal::GeneratorImpl
;
42 EVAF_INFO("%s created", qPrintable(objectName()));
49 EVAF_INFO("%s destroyed", qPrintable(objectName()));
52 bool Module::init(const QString
& args
)
56 if (!mGenerator
->init())
61 EVAF_INFO("%s initialized", qPrintable(objectName()));
72 EVAF_INFO("%s finalized", qPrintable(objectName()));
76 //-------------------------------------------------------------------
78 using namespace eVaf::PswGen::Generator::Internal
;
80 GeneratorImpl::GeneratorImpl()
83 setObjectName(QString("%1.iGenerator").arg(VER_MODULE_NAME_STR
));
85 Common::iRegistry::instance()->registerInterface("iGenerator", this);
87 EVAF_INFO("%s created", qPrintable(objectName()));
90 GeneratorImpl::~GeneratorImpl()
92 EVAF_INFO("%s destroyed", qPrintable(objectName()));
95 bool GeneratorImpl::init()
97 EVAF_INFO("%s initialized", qPrintable(objectName()));
102 void GeneratorImpl::done()
104 EVAF_INFO("%s finalized", qPrintable(objectName()));
107 QString
GeneratorImpl::generatePassword(char const * const name
, char const * const masterPassword
, int length
, uint flags
)
109 QByteArray inputString
= QString("%1%2").arg(name
).arg(masterPassword
).toLatin1();
110 QCryptographicHash
hash(QCryptographicHash::Md5
);
111 hash
.addData(inputString
);
112 QByteArray result
= hash
.result().toBase64();
114 return result
.left(length
);
120 //-------------------------------------------------------------------
122 VER_EXPORT_VERSION_INFO()
123 Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR
, Module
)