<?php
// Get random password
function get_random_password($chars_min=8, $chars_max=12, $use_upper_case=true, $include_numbers=true, $include_special_chars=true)
{
$length = rand($chars_min, $chars_max);
$selection = 'aeuoyibcdfghjklmnpqrstvwxz';
if($include_numbers) {
$selection .= "1234567890";
}
if($include_special_chars) {
$selection .= "!@\"#$%&[]{}?|";
}
$password = "";
for($i=0; $i<$length; $i++) {
$current_letter = $use_upper_case ? (rand(0,1) ? strtoupper($selection[(rand() % strlen($selection))]) : $selection[(rand() % strlen($selection))]) : $selection[(rand() % strlen($selection))];
$password .= $current_letter;
}
return $password;
}
?>
AND CALL THIS :-
<?php
$random_key = get_random_password($chars_min=6, $chars_max=8, $use_upper_case=true, $include_numbers=true, $include_special_chars=false);
echo $random_key;
?>
// Get random password
function get_random_password($chars_min=8, $chars_max=12, $use_upper_case=true, $include_numbers=true, $include_special_chars=true)
{
$length = rand($chars_min, $chars_max);
$selection = 'aeuoyibcdfghjklmnpqrstvwxz';
if($include_numbers) {
$selection .= "1234567890";
}
if($include_special_chars) {
$selection .= "!@\"#$%&[]{}?|";
}
$password = "";
for($i=0; $i<$length; $i++) {
$current_letter = $use_upper_case ? (rand(0,1) ? strtoupper($selection[(rand() % strlen($selection))]) : $selection[(rand() % strlen($selection))]) : $selection[(rand() % strlen($selection))];
$password .= $current_letter;
}
return $password;
}
?>
AND CALL THIS :-
<?php
$random_key = get_random_password($chars_min=6, $chars_max=8, $use_upper_case=true, $include_numbers=true, $include_special_chars=false);
echo $random_key;
?>
No comments:
Post a Comment