Generate A Random Password With PHP

Share your thoughts

One Reply to “Generate A Random Password With PHP”

  1. rand() is a pretty terrible way to get a random number out of PHP. I’d definitely suggest replacing it with random_int ( for PHP 7 and higher) that will use a true random number generator.

    Also, I’d probably add in a check to make sure the password matches a certain policy: at least 8 characters, at least one capital letter, at least one lowercase letter, at least one number, at least one special character. If it doesn’t meet this criteria, regenerate.

Leave a Reply

Your email address will not be published. Required fields are marked *