]>
vaikene.ee Git - evaf/blob - src/apps/PswGen/Generator/module.cpp
27354f52a630575fa5e9e1ff3f99d3f58b501923
2 * @file PswGen/Generator/module.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.
23 #include <Common/iLogger>
24 #include <Common/iRegistry>
28 VER_EXPORT_VERSION_INFO()
29 Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR
, eVaf::PswGen::Generator::Module
)
32 using namespace eVaf::PswGen
;
33 using namespace eVaf::PswGen::Generator
;
35 //-------------------------------------------------------------------
40 setObjectName(QString("%1.%2").arg(VER_MODULE_NAME_STR
).arg(__FUNCTION__
));
42 mGenerator
= new Internal::GeneratorImpl
;
44 EVAF_INFO("%s created", qPrintable(objectName()));
51 EVAF_INFO("%s destroyed", qPrintable(objectName()));
54 bool Module::init(QString
const & args
)
58 EVAF_INFO("%s initialized", qPrintable(objectName()));
65 EVAF_INFO("%s finalized", qPrintable(objectName()));
69 //-------------------------------------------------------------------
71 using namespace eVaf::PswGen::Generator::Internal
;
73 GeneratorImpl::GeneratorImpl()
76 setObjectName(QString("%1.iGenerator").arg(VER_MODULE_NAME_STR
));
78 Common::iRegistry::instance()->registerInterface("iGenerator", this);
80 EVAF_INFO("%s created", qPrintable(objectName()));
83 GeneratorImpl::~GeneratorImpl()
85 EVAF_INFO("%s destroyed", qPrintable(objectName()));
88 QString
GeneratorImpl::generatePassword(QString
const & name
, QString
const & masterPassword
, int length
, uint flags
) const
92 QByteArray inputString
= QString("%1%2").arg(name
).arg(masterPassword
).toLatin1();
93 QCryptographicHash
hash(QCryptographicHash::Md5
);
94 hash
.addData(inputString
);
95 QByteArray result
= hash
.result().toBase64();
97 return result
.left(length
);