-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkpass.cpp
More file actions
69 lines (64 loc) · 1.3 KB
/
Copy pathmkpass.cpp
File metadata and controls
69 lines (64 loc) · 1.3 KB
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
#include <iostream>
#include <cstdlib>
#include <climits>
#include <cassert>
#include <sstream>
#ifdef __cplusplus
extern "C" {
#endif
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <error.h>
#include <errno.h>
#ifdef __cplusplus
}
#endif
#include "pass.h"
#include "config.h"
using namespace std;
#define DEFAULT_PASS_LENGTH 16
int main(int argc, char *argv[])
{
int N = DEFAULT_PASS_LENGTH;
int alpha = 0;
int Alpha = 0;
int number = 0;
int symbol = 0;
int use_urandom = 1; // use /dev/random or /dev/urandom
int opt;
while((opt = getopt(argc, argv, "a:A:n:s:N:r")) != -1) {
switch(opt) {
case 'a':
alpha = atoi(optarg);
break;
case 'A':
Alpha = atoi(optarg);
break;
case 'n':
number = atoi(optarg);
break;
case 's':
symbol = atoi(optarg);
break;
case 'N':
N = atoi(optarg);
break;
case 'r':
use_urandom = 0;
break;
default:
cerr<<"Usage: %s [-a n] [-A n] [-n n] [-s n] [-N n] [-r]"<<endl;
cerr<<"Please report any bugs to "<<PACKAGE_BUGREPORT<<endl;
exit(-1);
}
}
int randtype;
if(use_urandom)
randtype = Rand::RAND_TYPE_PSEUDO_RANDOM;
else
randtype = Rand::RAND_TYPE_RANDOM;
Pass p(N, alpha, Alpha, number, symbol, randtype);
cout<<p<<endl;
}