-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
132 lines (112 loc) · 3.58 KB
/
index.php
File metadata and controls
132 lines (112 loc) · 3.58 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
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
<html>
<head>
<title>~PWGEN</title>
<body>
<font size="4">
<i>~PWGEN~ by Vincent</i>
</font>
<?php
$alpha = "abcdefghijklmnopqrstuvwxyz"; //Lower Case Letters: (a-z)
$alpha_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //Upper Case Letters: (A-Z)
$numeric = "0123456789"; //Numbers: (0-9)
$special = "~`!@#$%^&*()_-+={[}]|\":;'<,>.?/\\"; //Special Characters or Symbols
$chars = "";
if (isset($_POST['length'])){
// if you want a form like above
if (isset($_POST['alpha_lower_include']) && $_POST['alpha_lower_include'] == 'yes')
$chars .= $alpha;
if (isset($_POST['alpha_upper_include']) && $_POST['alpha_upper_include'] == 'yes')
$chars .= $alpha_upper;
if (isset($_POST['number_include']) && $_POST['number_include'] == 'yes')
$chars .= $numeric;
if (isset($_POST['symbol_include']) && $_POST['symbol_include'] == 'yes')
$chars .= $special;
$length = $_POST['length'];
}else{
$chars = $alpha . $alpha_upper . $numeric;
$length = 12;
}
$len = strlen($chars);
$pw = '';
for ($i=0;$i<$length;$i++)
$pw .= substr($chars, rand(0, $len-1), 1);
$pw = str_shuffle($pw);
?>
<form method="post" action="">
<p>
Include Alpha Uppercase (A-Z): <select name="alpha_upper_include" id="alpha_upper_include">
<?php
$alpha_upper_include = array( 'yes' => "Yes", 'no' => "No" );
foreach( $alpha_upper_include as $key => $val ):
$selected = '';
if( $key == $_POST['alpha_upper_include'] ) {
$selected = 'selected="selected"';
}
?>
<option value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo $val; ?></option>
<?php
endforeach;
?>
</select>
</p>
<p>
Include Alpha Lowercase (a-z): <select name="alpha_lower_include" id="alpha_lower_include">
<?php
$alpha_lower_include = array( 'yes' => "Yes", 'no' => "No" );
foreach( $alpha_lower_include as $key => $val ):
$selected = '';
if( $key == $_POST['alpha_lower_include'] ) {
$selected = 'selected="selected"';
}
?>
<option value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo $val; ?></option>
<?php
endforeach;
?>
</select>
</p>
<p>
Include Number (0-9): <select name="number_include" id="number_include">
<?php
$number_include = array( 'yes' => "Yes", 'no' => "No" );
foreach( $number_include as $key => $val ):
$selected = '';
if( $key == $_POST['number_include'] ) {
$selected = 'selected="selected"';
}
?>
<option value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo $val; ?></option>
<?php
endforeach;
?>
</select>
</p>
<p>
Include Symbol: <select name="symbol_include" id="symbol_include">
<?php
$symbol_include = array( 'yes' => "Yes", 'no' => "No" );
foreach( $symbol_include as $key => $val ):
$selected = '';
if( $key == $_POST['symbol_include'] ) {
$selected = 'selected="selected"';
}
?>
<option value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo $val; ?></option>
<?php
endforeach;
?>
</select>
</p>
<?php
$length = ( empty($_POST['length']) ) ? 12 : $_POST['length'] ;
?>
<p>Password Length: <input type="text" name="length" value="<?php echo $length; ?>" /></p>
<input type="submit" name="submit" value="Generate Password" />
</form>
Password: <?php echo $pw; ?>
<p>
<?php echo '<a href="https://xkcd.com/936/"><img src="https://imgs.xkcd.com/comics/password_strength.png" /></a>'; ?>
</p>
</body>
</head>
</html>