How to create (multiple) secure passwords in PHP?

I am trying to come up with a function that can generate random passwords that must meet the following requirements:

  • Between 8 and 14 characters
  • Contains at least one of the following: lowercase, uppercase, punctuation, and number

what would be best in this, so that the function can generate all possible passwords that match the specified requirements?

+3
source share
4 answers
  • Create a lowercase letter, uppercase letter, character and punctuation number, so now you have 4 characters.
  • Generate 4-10 random characters from the entire set above.
  • Shuffle the resulting string. In PHP you can use str_shuffle.

, , , , / .., . , , , .

+6

Google "PHP Password Generator" ( ). , .

rand(). , . mt_rand() .

, (.. /dev/random linux Utilities Windows).

+1

:

8 14 , , //etc , .

0

sha1. - , , , :

sha1(microtime() . rand(0,100))

, -, , , , , , .

0

Source: https://habr.com/ru/post/1723145/


All Articles