Last active
October 29, 2020 00:17
-
-
Save ggwebdev/0bf36cc1c2f994b0f49a to your computer and use it in GitHub Desktop.
Make Rand Pass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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