]> vaikene.ee Git - evaf/blob - src/apps/PswGen/Generator/igenerator.h
Work started on 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
27 namespace eVaf {
28 namespace PswGen {
29
30 /**
31 * Password generator interface.
32 *
33 * This interface is used to generate strong passwords.
34 */
35 class PSWGEN_GENERATOR_EXPORT iGenerator : public QObject
36 {
37 Q_OBJECT
38
39 public:
40
41 /// Interface constructor
42 iGenerator() {}
43
44 /// Empty virtual destructor
45 virtual ~iGenerator() {}
46
47 /**
48 * Flags for the password generator.
49 */
50 enum {
51 ALPHANUMERIC = 0x01 ///< Generated password contains only alphanumeric characters
52 };
53
54 /**
55 * Default length of the generated password
56 */
57 enum {
58 DEFAULT_LENGTH = 16
59 };
60
61 /**
62 * Generates a strong password
63 * @param name Name of the password
64 * @param masterPassword Master password
65 * @param length Length of the password
66 * @param flags Flags for the generator
67 * @return Generated password
68 *
69 * This function generates a strong password using the name and the master password string
70 * as inputs. Calling this function with the same input always returns the same generated
71 * password.
72 *
73 * The length of the password is specified with the length argument. However, the generated password
74 * is never longer than possible with the particular cryptographic method.
75 *
76 * Optional flags can be used to fine-tune the generator.
77 */
78 virtual QString generatePassword(char const * const name, char const * const masterPassword, int length = DEFAULT_LENGTH, uint flags = 0) = 0;
79
80 /**
81 * Returns the maximum length of generated passwords
82 * @return Maximum length
83 *
84 * This function returns the maximum length of generated passwords that is possible with the cryptographic method
85 * used by the module implementing this interface.
86 */
87 virtual int maxLength() const = 0;
88
89 };
90
91 } // namespace eVaf::PswGen
92 } // namespace eVaf
93
94 #endif // igenerator.h