summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/genpasswd.h
Unidiff
Diffstat (limited to 'pwmanager/pwmanager/genpasswd.h') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/genpasswd.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/pwmanager/pwmanager/genpasswd.h b/pwmanager/pwmanager/genpasswd.h
new file mode 100644
index 0000000..3fa1607
--- a/dev/null
+++ b/pwmanager/pwmanager/genpasswd.h
@@ -0,0 +1,76 @@
1/***************************************************************************
2 * *
3 * copyright (C) 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. *
9 * *
10 ***************************************************************************/
11
12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde
16 *
17 * $Id$
18 **************************************************************************/
19
20#ifndef __GENPASSWD_H
21#define __GENPASSWD_H
22
23#include <qstring.h>
24#include <qptrlist.h>
25
26/** internal password generator of PwManager */
27class GenPasswd
28{
29protected:
30 struct dynCharset_element
31 {
32 /** charset data */
33 QString data;
34 /** reference counter for the filter */
35 unsigned int refCnt;
36 };
37
38public:
39 GenPasswd();
40
41 /** set the charset to use */
42 void setCharset(bool lower,
43 bool upper,
44 bool num,
45 bool special,
46 bool blank,
47 QString user);
48 /** set the password length */
49 void setLen(int len)
50 { length = len; }
51 /** use the filter? */
52 void setUseFilter(bool use)
53 { useFilter = use; }
54 /** start to generate a new password and return it.
55 * Returns an empty string on error.
56 */
57 QString gen();
58
59protected:
60 /** randomize the dynamic charset */
61 void rndDynCharset();
62 /** select the next charset (based on useFilter) */
63 dynCharset_element * selectNextCharset();
64 /** generate a new random char from the given charset */
65 QChar genNewRandom(const dynCharset_element *charset);
66
67protected:
68 /** password length to generate */
69 int length;
70 /** use the filter? */
71 bool useFilter;
72 /** dynamic charset used for generating the password */
73 QPtrList<dynCharset_element> dynCharset;
74};
75
76#endif // __GENPASSWD_H