]> vaikene.ee Git - evaf/blob - src/apps/PswGen/Generator/igenerator.h
Modified the PswGen application to follow the tutorial.
[evaf] / src / apps / PswGen / Generator / igenerator.h
1 /**
2 * @file PswGen/Generator/igenerator.h
3 * @brief Interface for password generator modules
4 * @author Enar Vaikene
5 *
6 * Copyright (c) 2011 Enar Vaikene
7 *
8 * This file is part of the eVaf C++ cross-platform application development framework.
9 *
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.
15 *
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
18 */
19
20 #ifndef __PSWGEN_GENERATOR_IGENERATOR_H
21 # define __PSWGEN_GENERATOR_IGENERATOR_H
22
23 #include "lib.h"
24
25 #include <QObject>
26 #include <QString>
27
28 namespace eVaf {
29 namespace PswGen {
30
31 /**
32 * Password generator interface.
33 *
34 * This interface is used to generate strong passwords.
35 */
36 class PSWGEN_GENERATOR_EXPORT iGenerator : public QObject
37 {
38 Q_OBJECT
39
40 public:
41
42 /// Interface constructor
43 iGenerator() : QObject() {}
44
45 /// Empty virtual destructor
46 virtual ~iGenerator() {}
47
48 /**
49 * Flags for the password generator.
50 */
51 enum {
52 ALPHANUMERIC = 0x01 ///< Generated password contains only alphanumeric characters
53 };
54
55 /**
56 * Generates a strong password
57 * @param name Name of the password
58 * @param masterPassword Master password
59 * @param length Length of the password (if zero, then uses the max length)
60 * @param flags Flags for the generator
61 * @return Generated password
62 *
63 * This function generates a strong password using the name and the master password string
64 * as inputs. Calling this function with the same input always returns the same generated
65 * password.
66 *
67 * The length of the password is specified with the length argument. However, the generated password
68 * is never longer than possible with the particular cryptographic method.
69 *
70 * Optional flags can be used to fine-tune the generator.
71 */
72 virtual QString generatePassword(QString const & name, QString const & masterPassword, int length, uint flags = 0) const = 0;
73
74 /**
75 * Returns the maximum length of generated passwords
76 * @return Maximum length
77 *
78 * This function returns the maximum length of generated passwords that is possible with the cryptographic method
79 * used by the module implementing this interface.
80 */
81 virtual int maxLength() const = 0;
82
83 };
84
85 } // namespace eVaf::PswGen
86 } // namespace eVaf
87
88 #endif // igenerator.h