Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,21 @@
}else{
$dashes=false;
}

if($title=='includes'){
$includes=$info;
}

}

}
if($sets==null){
echo '<div class="alert alert-danger" role="alert"><strong>Generation Error:</strong> Please Define some Parameters </div>';

} else{
echo '<div class="alert alert-success" role="alert"><strong>New Password:</strong> '.generateStrongPassword($length,$dashes, $sets).'</div>';
echo '<div class="alert alert-success" role="alert"><strong>New Password:</strong> '.generateStrongPassword($length,$dashes, $sets,$includes).'</div>';
}
function generateStrongPassword($length = 27, $add_dashes = false, $available_sets = 'luda')
function generateStrongPassword($length = 27, $add_dashes = false, $available_sets = 'luda',$includes)
{
$sets = array();
if(strpos($available_sets, 'l') !== false)
Expand All @@ -59,18 +64,19 @@ function generateStrongPassword($length = 27, $add_dashes = false, $available_se
$password .= $all[array_rand($all)];

$password = str_shuffle($password);
$end = $password."".$includes;

if(!$add_dashes)
return $password;
return $end;

$dash_len = floor(sqrt($length));
$dash_str = '';
while(strlen($password) > $dash_len)
while(strlen($end) > $dash_len)
{
$dash_str .= substr($password, 0, $dash_len) . '-';
$password = substr($password, $dash_len);
$dash_str .= substr($end, 0, $dash_len) . '-';
$end = substr($end, $dash_len);
}
$dash_str .= $password;
$dash_str .= $end;
return $dash_str;
}
?>
?>
8 changes: 6 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
a=$("#a").is(':checked');
dashes=$("#dashes").is(':checked');
length=$("#length").val();
includes=$("#include").val();
$.ajax({
url: 'generate.php',
type:'POST',
Expand All @@ -28,7 +29,8 @@
s: s,
a: a,
dashes: dashes,
length: length
length: length,
includes: includes
},
success: function(data)
{
Expand Down Expand Up @@ -89,6 +91,8 @@
<span class="custom-control-description">Include Dashes</span>
</label><br>

<input type="text" class="form-control" id="include" name="include" required="required" placeholder="Include this Character" /><br>

</div>

<button type="button" onclick="generate()" class="btn btn-danger btn-lg btn-block">Generate Password</button>
Expand All @@ -104,4 +108,4 @@
</div>
<div style="float: right;padding: 20px;color: #bfbfbf;">Created By <a href="http://github.com/hmrserver/">HMR</a> © 2016 - <?php echo date('Y');?></div>
</body>
</html>
</html>