-
-
Save tylerhall/521810 to your computer and use it in GitHub Desktop.
<?PHP | |
// Generates a strong password of N length containing at least one lower case letter, | |
// one uppercase letter, one digit, and one special character. The remaining characters | |
// in the password are chosen at random from those four sets. | |
// | |
// The available characters in each set are user friendly - there are no ambiguous | |
// characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option, | |
// makes it much easier for users to manually type or speak their passwords. | |
// | |
// Note: the $add_dashes option will increase the length of the password by | |
// floor(sqrt(N)) characters. | |
function generateStrongPassword($length = 9, $add_dashes = false, $available_sets = 'luds') | |
{ | |
$sets = array(); | |
if(strpos($available_sets, 'l') !== false) | |
$sets[] = 'abcdefghjkmnpqrstuvwxyz'; | |
if(strpos($available_sets, 'u') !== false) | |
$sets[] = 'ABCDEFGHJKMNPQRSTUVWXYZ'; | |
if(strpos($available_sets, 'd') !== false) | |
$sets[] = '23456789'; | |
if(strpos($available_sets, 's') !== false) | |
$sets[] = '!@#$%&*?'; | |
$all = ''; | |
$password = ''; | |
foreach($sets as $set) | |
{ | |
$password .= $set[array_rand(str_split($set))]; | |
$all .= $set; | |
} | |
$all = str_split($all); | |
for($i = 0; $i < $length - count($sets); $i++) | |
$password .= $all[array_rand($all)]; | |
$password = str_shuffle($password); | |
if(!$add_dashes) | |
return $password; | |
$dash_len = floor(sqrt($length)); | |
$dash_str = ''; | |
while(strlen($password) > $dash_len) | |
{ | |
$dash_str .= substr($password, 0, $dash_len) . '-'; | |
$password = substr($password, $dash_len); | |
} | |
$dash_str .= $password; | |
return $dash_str; | |
} |
Good work!
Thanks a lot!
thanks!
try this simple code : http://www.sanwebcorner.com/2017/08/generate-password-to-textbox-using-php.html
A very good script. Thank you so much.
thank you 👍
Thank you dude! vk.com here)
thank you
thanks!
make a forked version of this script, whit some improvments in crypt functions
https://gist.github.com/compermisos/cf11aed742d2e1fbd994e083b4b0fa78
See my implementation works with all chars languages.
Here is easy https://www.dohangout.com/forum/viewtopic.php?f=23&t=333 no need to create password. 14 million password. Enjoy
I generate mine like this... http://tools.webbatlas.com but i need to include few symbols on this project
Thks a lot
Great! many many thanks!!!
Amazing!
Very good work. Thanks.
Thanks a lot
thank you kind sir
Thanks,Very Useful