-
Notifications
You must be signed in to change notification settings - Fork 0
/
passwordgenerator.h
137 lines (119 loc) · 3.94 KB
/
passwordgenerator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/**
* PasswordMaker - Creates and manages passwords
* Copyright (C) 2006 Eric H. Jung and LeahScape, Inc.
* http://passwordmaker.org/
* grimholtz@yahoo.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Written by Miquel Burns <miquelfire@gmail.com> and Eric H. Jung
*/
#ifndef PASSWORDMAKER_H
#define PASSWORDMAKER_H
#include <QObject>
#include "shared/pwm_common.h"
class Hasher;
class PWMAccount;
class PasswordGenerator : public QObject {
Q_OBJECT
public:
PasswordGenerator(QObject *parent);
/**
* Returns true if everything is ready to start generating passwords.
* If false, you can use the getError function to tell the user what may be
* wrong. Using setPath(QString) may fix the error if it was because the
* getHash.qs file was not found however.
*/
bool initialized() { return aOK; };
/**
* Returns the last error
*/
QString getError() { return error; };
/**
* Clears the last error
*/
void clearError() { error = ""; };
void getSettings(PWMAccount *s);
public slots:
/**
* Calling this function will generate a password based on the current
* settings and the master password supplied.
*/
QString generatePassword(QString masterPassword);
/**
* Pass an instance of AccountSettings to autopopulate all the settings for
* an account. Other functions are for use when changing directly from the
* GUI itself
*/
void setSettings(PWMAccount *s);
/**
* The following functions set of functions set the values of the parameters
* used to generate a password. Normally, setSettings() would set these
* values anyway.
*/
void setAlgorithm(hashType a);
void setFullAlgorithm(int a); // Direct support for combobox data
void setHMAC(bool h);
void setTrim(bool t);
void setURL(QString url);
void setPasswordLength(int l);
void setPasswordLength(QString l);
void setCharacterSet(QString c);
void setUseLeet(leetType l);
void setLeetLevel(int l); // Range is 0-8
void setUserName(QString u);
void setModifier(QString m);
void setPrefix(QString p);
void setSuffix(QString s);
void setHMACBug(bool b);
signals:
/**
* Emitted whenever a setting is changed. setSettings() will only cause this
* to be emitted once
*/
void settingChanged();
/**
* The following are emitted when the setting has been changed, so that GUI
* objects can be adjusted
*/
void algorithmChanged(hashType a);
void fullAlgorithmChanged(int a);
void HMACChanged(bool h);
void trimChanged(bool t);
void URLChanged(QString url);
void passwordLengthChanged(int l);
void characterSetChanged(QString c);
void useLeetChanged(leetType l);
void leetLevelChanged(int l);
void userNameChanged(QString u);
void modifierChanged(QString m);
void prefixChanged(QString p);
void suffixChanged(QString s);
void HMACBugChanged(bool b);
/**
* Emitted whenever generatePassword is called
*/
void passwordGenerated(QString password);
private:
QString urlToUse, charset, username, modifier, prefix, suffix, error;
int passwordLength, leetLevel, fullAlgorithm;
bool useHMAC, useTrim, HMACBug, useHex, aOK;
hashType algorithm;
leetType useLeet;
bool massChange;
// Custom classes being used
Hasher *hasher;
};
#endif //PASSWORDMAKER_H