Skip to content

Instantly share code, notes, and snippets.

@ggwebdev
Last active October 29, 2020 00:17
Show Gist options
  • Save ggwebdev/0bf36cc1c2f994b0f49a to your computer and use it in GitHub Desktop.
Save ggwebdev/0bf36cc1c2f994b0f49a to your computer and use it in GitHub Desktop.
Make Rand Pass
function randPass($leng = 20, $uppercase = true, $number = true, $simbol = true)
{
$lower = 'abcdefghijklmnopqrstuvwxyz';
$upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$numbers = '1234567890';
$simbols = '?@[#_>(!&]{$*=<%}+)-^~';
$password = '';
$characters = '';
$character .= $lower;
if ($uppercase) $characters .= $upper;
if ($number) $characters .= $numbers;
if ($simbol) $characters .= $simbols;
$len = strlen($characters);
for ($n = 1; $n <= $leng; $n++) {
$password .= $characters[random_int(0, $len)];
}
return $password;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment