How To Generate (Somewhat) Secure Passwords in PHP?

php

Solution

- Generate a lowercase letter, uppercase letter, punctuation symbol and number, so you now have 4 characters.

- Generate 4-10 random characters from the entire set of above.

- Shuffle the resulting string. In PHP you can use `str_shuffle`.

However, it should be noted that if you're generating random characters, forcing every password to have at least one number/punctuation etc is not really any more secure. In fact, you could say it's less secure since it actually limits your password choices.

Problem

I'm trying to come up with a function that can generate random passwords, that must meet the following requirements: - Between 8 & 14 characters - Contain a least one of the following: lowercase letter, uppercase letter, punctuation, and number what would be the best way about going about this, such that the function can generate every possible password that meets said requirements?

Original source